Seasons123 / ADReact

component:advertising section :rainbow:
10 stars 1 forks source link

componentWillReceiveProps怎么触发 #38

Open Seasons123 opened 7 years ago

Seasons123 commented 7 years ago

componentWillReceiveProps() is invoked before a mounted component receives new props. If you need to update the state in response to prop changes (for example, to reset it), you may compare this.props and nextProps and perform state transitions using this.setState() in this method.

当组件传入的 props 发生变化时调用,例如:父组件状态改变,给子组件传入了新的prop值。用于组件 props 变化后,更新state。