When to use Component or PureComponent
Reference: https://codeburst.io/when-to-use-component-or-purecomponent-a60cfad01a81 When to use Component or PureComponent I switched to using PureComponent awhile back on the premise of it being a more performant version of Component. This turned out to be true, but the performance gains come with a few strings attached. Let’s dig in to PureComponent and understand why we should be using it. Component and PureComponent have one difference PureComponent is exactly the same as Component except that it handles the shouldComponentUpdate method for you . When props or state changes, PureComponent will do a shallow comparison on both props and state. Component on the other hand won’t compare current props and state to next out of the box. Thus, the component will re-render by default whenever shouldComponentUpdate is called. Shallow Comparison 101 When comparing previous props and state to next, a shal...