如何forwardRef
在具有连接功能的类组件中使用react-redux
?
import React, { Component } from 'react';
import ChildComponent from './ChildComponent';
class ParentComponent extends Component {
constructor(props) {
super(props);
this.myRef = React.createRef();
}
render() {
return <ChildComponent ref={this.myRef} />;
}
}
export default ParentComponent;
子组件
import React, { Component } from 'react';
import { TextInput } from 'react-native';
import { connect } from 'react-redux';
class ChildComponent extends Component {
render() {
return <TextInput value={'Hi'} ref={??} />;
}
}
export default connect(null, null, null, { forwardRef: true })(ChildComponent);
我不知道如何React.forwardRef()
在类组件中使用。