日志显示我的父组件正在重新提交自身
但未调用子组件的渲染方法。
我认为《儿童》重播有以下逻辑,我认为我错了。当父组件重新渲染时,react如何决定重新渲染哪些子组件?
父渲染看起来像
render() {
let { viewConfig } = this.props
console.log("ViewConfigSettingBase rendering")
return (
<div>
{
Object.keys(viewConfig.availableSubviewConfigMap).map((sectionName, index) => {
var subviewConfigData = viewConfig.availableSubviewConfigMap[sectionName]
return (
<ViewConfigSettingRow
key={sectionName}
viewConfigData={subviewConfigData}
sectionName={sectionName}
parentViewConfig={viewConfig}
/>
)
})
}
</div>
)
}
对道具或状态更改进行重新渲染。如果你扩展了一个PureComponent,孩子们会检查道具是否发生了变化。如果是的话-
组件生命周期:https://facebook.github.io/react/docs/react-component.html
更新中
道具或状态的更改可能会导致更新。这些方法是
componentWillReceiveProps()
shouldComponentUpdate()
componentWillUpdate()
render()
componentDidUpdate()
shouldComponentUpdate()
使用shouldComponentUpdate()让React知道组件的输出是否正确
当新道具或
返回false不会阻止子组件在
当前,如果shouldComponentUpdate()返回false,则
如果在分析后确定特定组件速度较慢,则可以
您可以在以下页面找到一些关于反应渲染过程的留档:https://facebook.github.io/react/docs/reconciliation.htmlhttps://facebook.github.io/react/docs/optimizing-performance.html