Pure Component trong Class Component là React.PureComponent, tự động implement shouldComponentUpdate với shallow comparison của props và state.
- Trong Function Component, tương đương là React.memo() wrap component.
- Hữu ích để tránh re-render không cần thiết khi props không thay đổi.
- Shallow comparison có thể bỏ qua thay đổi của nested objects.
In class-based React, a Pure Component is React.PureComponent, which automatically implements shouldComponentUpdate with a shallow comparison of props and state.
- The Function Component equivalent is wrapping with React.memo().
- Both are useful for preventing unnecessary re-renders when props have not actually changed.
- Be aware that shallow comparison can miss changes inside nested objects.