Reactjs 在';t工作(状态仍然相同)
我调用这个函数:Reactjs 在';t工作(状态仍然相同),reactjs,callback,parent-child,state,onchange,Reactjs,Callback,Parent Child,State,Onchange,我调用这个函数: dataChanged(data) { // data = { description: "New validated text comes here" } // Update your model from here console.log(data) this.setState({data}, function(){ console.log(this.state) }) } 但我还是有同样的状态 我称之为
dataChanged(data) {
// data = { description: "New validated text comes here" }
// Update your model from here
console.log(data)
this.setState({data}, function(){
console.log(this.state)
})
}
但我还是有同样的状态
我称之为的元素:
<CollapsibleItem header="My Goal" icon='public'>
<InlineEdit
validate={this.customValidateText}
activeClassName="editing"
text={this.state.goal}
paramName="goal"
change={this.componentDidUpdate}
/>
</CollapsibleItem>
工作不太正常您可以发布日志语句的输出吗?尝试从{data}中删除括号。只需这样做。设置状态(数据、函数…仅删除括号有效!谢谢!!
componentDidUpdate(prevProps, prevState) {
if (this.state.goal !== prevState.goal) {
console.log(this.state)
}
}