componentDidUpdate prevProps 在使用 es6 和 Babel 时显示新值

componentDidUpdate prevProps shows new values when using es6 and Babel

查看 TodoMVC 应用程序 here. Code for the same is here

添加todo并编辑时,控制台记录的第一个值应该是编辑前的值,第二个值是编辑后的值。

但是,记录的两个值都是编辑后的值。 prevProps 没有通过。 Bill Fisher 在 js/jsx 中编写的原始 TodoMVC-flux 中没有发现此问题。

我认为这是 Babel 的一个错误,但我无法查明。

发生这种情况的原因是状态对象发生变异,并且在您采用不可变方法时得到解决。

在 Bill Fisher 编写的 TodoMVC-flux 中,他返回了一个新对象。

有关详细信息,请参阅 https://discuss.reactjs.org/t/componentdidupdate-prevprops-has-new-values-instead-of-old-when-using-es6-and-babel/3695