Say I have a component that renders children but those children can be redux connected or timer based updating components. The parent component does not know that. Yet, the parent component implements shouldComponentUpdate for performance optimizations.
class Container extends React.Component {
shouldComponentUpdate(nextProps, nextState) { return shallowCompare(this, nextProps, nextState) }
render() {
return <div>
<h1>{this.props.title}</h1>
{ children }
</div>
}
}
Lets say, Clock is a self updating/connected component. And in this constellation:
<Container title="Current Time">
<Clock/>
</Container>
would Clock still be updated when its properties change due to redux state changes or an internal timeout (however it its implemented) despite its parent component title never changes and therefore the componentShouldUpdate call returns false?
If Clock is receiving props from Container, and Container does not update because of shouldComponentUpdate, then Clock will not update. If it is connected to the store, then it should update because it will receive props directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With