fe icon indicating copy to clipboard operation
fe copied to clipboard

我希望在深入 React 之前知道这些

Open justjavac opened this issue 8 years ago • 4 comments

文章我希望在深入 React 之前知道这些

音频:无

视频:无


原文I wish I knew these before diving into React

justjavac avatar Nov 01 '17 06:11 justjavac

会玩

peterchealse avatar Nov 01 '17 06:11 peterchealse

即使 props 没有改变,也会调用 componentWillReceiveProps,因此需要在函数内部比较 this.props 和 nextProps
这句话是什么意思不太理解您要表达什么

1gehunzi avatar Dec 11 '17 05:12 1gehunzi

这句话解释为什么要比较 this.propsnextProps,因为即使 props 没有改变,也会调用 componentWillReceiveProps,而 componentWillReceiveProps 默认总是返回 true

justjavac avatar Dec 11 '17 05:12 justjavac

理解了 之前没注意过这个细节。 即使没有显性声明的 props 也会调用componentWillReceiveProps。

1gehunzi avatar Dec 11 '17 06:12 1gehunzi