Đị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.
Defining a component inside another component creates a new component type on every render.
- React sees it as a different component each time and unmounts/remounts instead of updating, causing state loss and performance issues.
- Always declare components at the module's top level.
- If they need data from the parent, pass it via props or use the children pattern.