[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.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript, react
Lĩnh vực
documentation

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.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
11.8k
Fork
7.9k
Merge trung bình
16 giờ 6 phút
Pull request đã merge (30 ngày)
7

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.

Issue khác của reactjs/react.dev

Tất cả issue của reactjs/react.dev

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.