父组件(hooks)
let richTextRef = {};<RichText getRichText={getRichText} content={content} onRef={ref => richTextRef = ref} />
子组件(class)
componentDidMount = () => {this.props.onRef && this.props.onRef(this);}componentWillReceiveProps(nextProps) {nextProps.onRef && nextProps.onRef(this);}reseditorState = (content) => {this.setState({editorState: content ||'-',})}
使用:
richTextRef.reseditorState();