Closed FallOutChonny closed 6 years ago
Ok, finally I found the approach solved it,
in main component, pass a onRef prop to AsyncComponent
<AsyncComponent
onRef={c => this.editor = c}
/>
in Async Component, return this
componentDidMount() {
this.props.onRef(this);
}
then you can do like so from main component.
this.editor.clear();
this.editor.focus();
I'm having a little problem. Say I have an async component that is encapsulated with react-async-component, like this:
then call its internal functions by refs
but will get
Uncaught TypeError: _this.editor.focus is not a function
error, and I useconsole.log(this.editor)
see it's a async component and has not focus function so that I can't access it.I spent a lot of time but still have no idea how to fix it, does anyone can help ? thanks 😄