When Might You Use React. Purecomponent?
Purecomponent Is Primarily Used for Performance Optimization. as Outlined in the React Docs: If Your React Component's Render() Function Renders the Same...
PureComponent Is Primarily Used for Performance Optimization. As outlined in the React docs: If your React component's render() function renders the same result given the same props and state, you can use React. PureComponent for a performance boost in some cases.
When should you use React PureComponent?
When to use PureComponent
To sum it up, PureComponent is useful when: You want to avoid re-rendering cycles of your component when its props and state are not changed, and. The state and props of your component are immutable, and. You don't plan to implement your own shouldComponentUpdate lifecycle method.
What is and how you can take advantage of PureComponent?
PureComponent gives a considerable increase in performance because it reduces the number of render operation in the application. The usage of the method shallowEqual tells us that only a shallow check of props and state will be made, which means that deeply nested objects and arrays will not be compared.