关于react的componentDidMount,componentWillReceiveProps,render的执行次数

1.比如弹出一个模态框,模态框中包括componentDidMount,componentWillReceiveProps,render,第一次打开模态框会执行componentDidMount,后面就再也不会执行了,render是只要有一个props就会执行执行,会执行很多次,而componentWillReceiveProps是只要某个状态改变才会执行(可以控制成某个状态改变的时候才会执行),

所以要想每次打开模态框都执行一次某个东西,就用componentWillReceiveProps(控制模态框打开的状态)


2.如果想要nextProps和this.props相同的时候也会改变,那么就用eventProxy

你可能感兴趣的:(关于react的componentDidMount,componentWillReceiveProps,render的执行次数)