reactjs / reactjs/react.dev

[Suggestion]: rename `useImperativeHandle` for clarity

Đang mở
#8,469 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

type: documentation
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ả

Summary

[!NOTE]
This is not specific to the docs site but I could not find an appropriate issue to file this under the main repo. Is this the appropriate place to discuss API naming and offer suggestions? If not, please let me know where I should redirect my question!

While the docs page does a good job of explaining how and when useImperativeHandle is used, I think it would be much clearer if the API were renamed to useProxy, useProxiedRef, useReflectedRef, or some other similar name as it makes it clearer that all you are doing is reflecting/proxying a ref that is passed in by consumers.

Page

https://react.dev/reference/react/useImperativeHandle

Details

"imperative" in imperativeHandle is unclear, should it be interpreted as important/necessary or imperative in the programming sense? Either way I don't think it's easy to understand. I've used this hook enough times by now that I am familiar with when/why it's needed but to someone new to React this is probably one of the more obscure hooks. Handle is also unclear as that has other meanings in other programming languages. I think "proxy" is a more universally understood term for "wrap/modify/mock something and pass it along" which is what this hook is doing.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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 useImperativeHandle được tham chiếu tại react.dev/reference/react/useImperativeHandle và xem xét liệu repository tài liệu này có thể xử lý một thay đổi về cách đặt tên API hay không. Issue chỉ hoàn tất sau khi đề xuất về cách đặt tên được quyết định hoặc cuộc thảo luận được chuyển hướng đến repository chính phù hợp.

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ính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.