class App extends React.Component {
constructor(props) {
super(props)
this.state = {}
}
_change = (e) => {
this.setState({ value: e.target.value });
}
refCallback = (el) => {
console.log("change")
}
_style = { backgroundColor: 'red', marginTop: 30 }
render() {
return <TextInput
style={this._style}
ref={this.refCallback}
type="text"
value={this.state.value}
onChange={this._change}
/>
}
}
每次我在 TextInput 中输入时都会调用 refCallBack
我尝试过网络,没有遇到问题。“当 DOM 节点添加到屏幕上时,React 将以 DOM 节点作为参数调用您的 ref 回调。当该 DOM 节点被删除时,React 将以 null 调用您的 ref 回调。”
当 DOM 安装和移除时,我应该被调用两次
我尝试使用输入(网络)->它有效 我尝试使用 TextInput (本机反应)-> 当输入安装和删除时应该调用两次