Missing documentation of `dispatch` function's stability
Chưa có ai nhận issue này.
- 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ả
First, I like the new React docs a lot! Unfortunately, I can no longer find the following information about useReducer that was once available in the docs:
The useReducer hook returns an array with two elements: the current state and a dispatch function. The dispatch function is used to update the state by calling it with an action object. The dispatch function returned by useReducer has a lifecycle similar to that of the component it is used in. It is created when the component mounts and destroyed when the component unmounts. The dispatch function is guaranteed to be stable across re-renders.
Is this no longer the case?
On page Lifecycle of Reactive Effects there is a note box saying "In some cases, React knows that a value never changes..." and mentioning useState and useRef. It would be ideal if the documentation would explicitly enumerate all the stable return values from hooks, i.e., the ones that share the lifecycle of their component.
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
Bắt đầu với trang Lifecycle of Reactive Effects và tài liệu useReducer hiện tại, sau đó so sánh chúng với các chi tiết về tính ổn định được trích dẫn trong issue. Truy vết nơi các bảo đảm về giá trị trả về của hook được ghi lại và cập nhật tài liệu liên quan để tính ổn định của dispatch và các giá trị hook ổn định theo chủ đích được nêu rõ và nhất quán.
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
- 48/100