组件中, 点击按钮, 调用父元素中的的onAgeChange函数, 但是在父元素中这里我们setState的修改后的age和修改之前prevState中age状态值是一样的,age都是18, 所以App...在服务端渲染时 componentDidMount 是不会被调用的,只会调用componentWillMount.
2.在componentWillMount中, 我们一般会用来异步获取数据, 但是在新版生命周期中...在目前16.3之前的react版本中 ,react是同步渲染的, 在componentWillMount中接口调用,有可能不会触发界面渲染,而在componentDidMount中渲染一定会触发界面渲染...,具体可以看这个issue
在16.3之后react开始异步渲染,在异步渲染模式下,使用componentWillMount会被多次调用,并且存在内存泄漏等问题
关于在componentWillMount...Provider 组件的 value prop 值发生变更时,其内部组件树中对应的 Consumer 组件会接收到新值并重新执行 children 函数。