What are Pure Components?

Technology CommunityCategory: ReactWhat are Pure Components?
VietMX Staff asked 3 years ago

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.