reactjs / reactjs/react.dev

A section quite vague

Đang mở
#6,293 1 bình luận 3 reaction 0 người được giao Xem trên GitHub

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ả

In https://react.dev/learn/responding-to-events#passing-handlers-as-alternative-to-propagation

You could add more code to this handler before calling the parent onClick event handler, too. This pattern provides an alternative to propagation. It lets the child component handle the event, while also letting the parent component specify some additional behavior. Unlike propagation, it’s not automatic. But the benefit of this pattern is that you can clearly follow the whole chain of code that executes as a result of some event.

If you rely on propagation and it’s difficult to trace which handlers execute and why, try this approach instead.

It is somewhat abstract what it is talking about. "You could add more code" -- add more code for what purpose?

"This pattern provides an alternative to propagation" alternative to propagation? Why do I need to rely on propagation in the first place? (and such that I now need an "alternative"?)

"while also letting the parent component specify some additional behavior." What additional behavior?

"But the benefit of this pattern is that you can clearly follow the whole chain of code that executes as a result of some event." Follow the chain? What do you mean?

"If you rely on propagation and it’s difficult to trace which handlers execute and why, try this approach instead." What approach? Why do we "rely on propagation" in the first place?

Can you talk about something specific. Perhaps using an example with specific things. Right now it is quite abstract.

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 bằng cách đọc phần “Passing Handlers as Alternative to Propagation” tại URL tài liệu React được liên kết và so sánh phần này với nội dung xung quanh về xử lý sự kiện. Chỉnh sửa phần giải thích bằng một ví dụ cụ thể làm rõ mục đích, hành vi của phần tử cha và chuỗi thực thi, sau đó kiểm tra xem các phát biểu trừu tượng được trích dẫn có dễ hiểu đối với người mới bắt đầu hay không.

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ó
3/5
Thời gian dự kiến
1-2 ngày
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
35/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.