Trung BìnhReact iconReact

Tại sao không nên tạo component trong component (inline components)?

Định nghĩa component bên trong component khác tạo new component type mỗi render, React unmount/remount thay vì update, gây mất state và performance issues.

  • Luôn khai báo components ở top-level module, hoặc ngoài parent component.
  • Nếu cần data từ parent, truyền qua props hoặc dùng children pattern.

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

Mở danh sách React