4 ms·
Put ref properties on the child components. Put public methods on the child components. You can then access the refs from the parent in the parent's componentDi
by AgentME 11y ago
Put ref properties on the child components. Put public methods on the child components. You can then access the refs from the parent in the parent's componentDidMount or componentDidUpdate methods.
- kruhft 11y agoTried that, couldn't figure out how to get it to work. Still didn't have access to child's state.
- mercurial 11y agoUse something like: <YourComponent ref={yourRef => this.yourRef = yourRef}/> I think you should be able to do this.yourRef.state, but if not, you can always implement a getState() method in YourComponent.