Re:React v16.6.0: lazy, memo and contextType
by mcintyre1994 on Wednesday October 24, 2018 @11:33AM
(#18293273)
Thanks for this explanation, that makes a lot of sense! :)
Re:React v16.6.0: lazy, memo and contextType
by sophiebits on Wednesday October 24, 2018 @11:40AM
(#18293352)
(typo: its children need to change)
1. We support using mutable objects in props. Even if a prop is reference identical to the last render, the component might be reading some property of it that has changed.
2. Checking equality of props takes time. In the (common) case where a parent rerenders and it’s children need to change in response, any time we spend comparing will be extra overhead on top of the actual render cost. Often rerendering is fast anyway and adding more comparisons only makes it slower.
Because of these, we don’t do these checks by default. Instead, we recommend adding memo/PureComponent/shouldComponentUpdate in places where you know it will make a difference.