Nâng CaoReact iconReact

Reconciliation algorithm trong React hoạt động như thế nào?

React dùng heuristic O(n) algorithm thay vì O(n³) để diff trees:

  • (1) Elements khác type → destroy và rebuild hoàn toàn.
  • (2) Cùng type → compare props, update chỉ những gì thay đổi.
  • (3) Lists dùng key để match elements giữa renders.

Hiểu algorithm giúp tránh bugs và tối ưu performance.

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

Mở danh sách React