A React component can be considered pure if it renders the same output for the same state and props. They are the components that do not re-render when the value of props and state has been updated with the same values thus they improve performance.
Pure components have some performance improvements and render optimizations since React implements the shouldComponentUpdate() method for them with a shallow comparison for props and state.
For class components like this, React provides the PureComponent base class. Class components that extend the React.PureComponent classes are treated as pure components.
To create a pure functional component in React, React provides a React.memo() API. Using the React.memo() API, the React functional component can be wrapped as follows to get the React Pure Functional Component.
They prevent the re-rendering if props and state are the same by a Shallow comparison of state and props
They handle shouldComponentUpdate implicitly
Increases performance.
Primitives: If props.count changes from 5 to 5, it won't re-render. (Correct)
Objects/Arrays: If you pass a new array literal [1, 2, 3] every time the parent renders, the Pure Component will re-render because the memory reference is different, even if the numbers inside are the same.
If you wrap a functional component with React.memo, what effect does that have on its re‑render behavior?
You notice a component re‑renders even though its props haven't changed. How would you use a pure component to stop the extra renders?
What happens if you pass a newly created object literal as a prop to a PureComponent on each render?
We have a list component that receives an array of items as a prop. After switching it to a PureComponent, the UI sometimes doesn't update when items are added. Why might that be, and how would you fix it?
A teammate changed a class component to extend PureComponent and we saw a child component stop receiving updated context. Explain why this could happen.
When would you choose React.memo over extending PureComponent, and what trade‑offs does each bring in a mixed codebase?
Our dashboard renders thousands of rows. We plan to convert many row components to PureComponent, but we also need dynamic theming. How do you ensure PureComponent doesn't block required updates?
We are refactoring a legacy codebase that mixes class, functional, and PureComponent. What strategy would you use to decide which components to convert and how would you measure the impact?
Explain how using PureComponent interacts with Redux's connect and selector memoization. What pitfalls could arise at scale?
A large monorepo contains hundreds of UI components, some pure and some not. Design a migration plan to standardize on pure components where beneficial while minimizing risk to downstream teams.
Consider a cross‑team component library that must support both server‑side rendering and client‑side hydration. How does PureComponent affect SSR consistency, and what policies would you set to avoid hydration mismatches?
When evaluating long‑term maintainability of a component library, how would you decide whether to expose a PureComponent API versus a regular component with internal memoization, considering versioning and backward compatibility?