What happens if you edit modules with exports that aren't React components in Fast Refresh?
What happens if you edit modules with exports that aren't React components in Fast Refresh?
Trong Fast Refresh của React Native, nếu bạn sửa một module export những thứ không phải React component (hằng số, hàm tiện ích, theme...), Fast Refresh sẽ chạy lại cả module đó lẫn mọi module import nó. Ví dụ Button.js và Modal.js cùng import theme.js, sửa theme.js thì cả hai component đều được cập nhật.
Ba trường hợp cần phân biệt:
Một file vừa export component vừa export giá trị khác (ví dụ một hằng số) cũng rơi vào trường hợp 2, nên các module import nó sẽ bị chạy lại.
Ví dụ:
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.