Trung BìnhReact iconReact

Pure Component là gì và nó khác gì Component thông thường?

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.

Xem toàn bộ React cùng filter theo level & chủ đề con.

Mở danh sách React