Refs获取子组件state使用(react)


class ArchiveStorage extends Component {
    constructor(props) {
        this.state = {
            selectedTemplateItem: '',
        }
        this.selectBoxRef = React.createRef();
    }
    componentDidMount() {
        console.log(this.selectBoxRef.current.state)
    }
    render() {
        const {templateArray} = this.state;
        return (
            <Layout style={{ height: '100%', backgroundColor: '#f0f2f5' }}>
                <Content>
                    <SelectBox ref={this.selectBoxRef}></SelectBox>
                </Content>
            </Layout>
        );
    }
}

你可能感兴趣的:(react)