反应setState回调不显示当前状态

时间:2019-05-28 16:45:28

标签: reactjs setstate

我已经处理了几个小时,这确实使我的大脑沸腾了。...

我在函数中有以下代码:

this.setState({disableFixedPeriods, allowApplyFilters: false}, () => {
    console.log("APP FINISHED DISABLING FIXED PERIODS: ", this.state.allowApplyFilters)
});

控制台显示“ APP FINABLED DISABLELING FIXED PERIODS:true”

我想念什么吗?

更新:

这是罪魁祸首:

  setFilter = (newFilters, callback) => {
    let stateFilters = { ...this.state.filters };
    let filters = Object.assign(stateFilters, newFilters);
    this.setState({ filters, allowApplyFilters: true }, callback);
  };

0 个答案:

没有答案