我收到此警告:
Function components cannot be given refs. Attemps to access this ref will fail. Did you mean to use React.forwardRef()?
父母:
constructor(props) {
super(props);
this.tElement = React.createRef();
}
compoenentDidMount() {
this.tElement .current.loadTx();
}
调用子组件:
<Tt ref={this.tElement } />
该子项是React.Cmponent
导出为react-redux connect:
import { connect } from 'react-redux';
class Tt extends Component {
loadTx = async () => {
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(TransactionHistoryScene);
我通过使用组件道具和状态来刷新组件来解决它。