Reactjs 我如何知道redux form resetForm()已完成?

Reactjs 我如何知道redux form resetForm()已完成?,reactjs,redux-form,Reactjs,Redux Form,我在项目中使用redux表单+react: //My components <button type="submit" className="btn btn-primary" onClick={this.getBuildingList.bind(this)}>Search</button> <button type="button" onClick={this.resetBuildForm.bind(this)}>Reset</button>

我在项目中使用
redux表单
+
react

//My components
<button type="submit" className="btn btn-primary" onClick={this.getBuildingList.bind(this)}>Search</button>
<button type="button"  onClick={this.resetBuildForm.bind(this)}>Reset</button>

//resetBuildingForm function
resetBuildingForm(){
    let { dispatch, resetForm, list } = this.props;
    resetForm();
    //when I resetForm, I want to search again
    this.getBuildingList();
}
//我的组件
搜寻
重置
//重置BuildingForm函数
重置BuildingForm(){
让{dispatch,resetForm,list}=this.props;
resetForm();
//当我重新设置表单时,我想再次搜索
这个.getBuildingList();
}

当我重置表单时,我想再次搜索,但当我在redux表单中获得状态时,我得到的状态是旧的而不是新的,我如何知道重置表单事件何时完成,状态何时更新?

当表单从
变为
原始
时,您可以监听

componentDidUpdate(prevProps) {
  if(this.props.pristine && !prevProps.pristine) {
    // we just reset
    this.getBuildingList()
  }
}

然后您可以调用
this.props.resetForm()
来启动重置。

这可能对像我这样的新手有所帮助。 自reduxForm版本6以来,
this.props.resetForm()
已更改为
this.props.reset()

见问题