Can the React docs state more rule of the custom Hook
- Ngôn ngữ chính
- JavaScript
- Star
- 11.8k
- Fork
- 7.9k
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 11
Mô tả
Could the custom Hook page https://reactjs.org/docs/hooks-custom.html
include one important rule:
https://github.com/reactjs/reactjs.org/pull/3557
Does any change of state in a custom Hook cause any component that uses it to re-render? Yes, when we use any Hook in our function, this function becomes a custom Hook, and when other components use it, any update of the state in this custom hook can cause the component to re-render. So we should not think of the custom Hook as a static function.
Or something along that line? Right now, it feels really magically that somehow, we define a function and it can magically cause another component to re-render itself.
A working example might even be added: https://codesandbox.io/s/suspicious-keller-blqey?file=/src/App.js
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Trước tiên, hãy xem lại trang về Hook tùy chỉnh tại https://reactjs.org/docs/hooks-custom.html và pull request liên quan #3557. Xác nhận phần giải thích dự kiến rằng các bản cập nhật state khiến những component sử dụng Hook tùy chỉnh được render lại, sau đó cập nhật tài liệu bằng cách diễn đạt hoặc ví dụ đã thống nhất và xác minh rằng trang được render chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, react
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100