What does “shouldComponentUpdate” do and why is it important?

Technology CommunityCategory: ReactWhat does “shouldComponentUpdate” do and why is it important?
VietMX Staff asked 3 years ago

What shouldComponentUpdate does is it’s a lifecycle method that allows us to opt out of setState reconciliation process for certain components (and their child components). If we know that a certain section of our UI isn’t going to change, there’s no reason to have React go through the trouble of trying to figure out if it should. By returning false from shouldComponentUpdate, React will assume that the current component, and all its child components, will stay the same as they currently are.