Add a docs link to the state_explicit_event_handlers error hint

Đang mở Phù hợp với người mới
#7,915 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
documentation, testing

Hướng nghiên cứu

Đọc docs/events/events_overview.md và _UNDECORATED_STATE_METHOD_HINT dùng chung trong reflex_base/event/__init__.py, sau đó tìm các kiểm thử cho on_load và các phương thức được trả về. Thêm tiêu đề ổn định và liên kết đến tài liệu như mô tả trong issue, đồng thời mở rộng các assertion trong cả hai kiểm thử để kiểm tra liên kết. Công việc hoàn tất khi cả ba nhánh lỗi dùng chung gợi ý có liên kết và hai kiểm thử xác nhận điều đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Follow-up to #7033 (state_explicit_event_handlers).

Problem

With state_explicit_event_handlers=True, Reflex raises a targeted error when an undecorated state method is used as an event. The error tells the user to add @rx.event, but it gives no link to the docs. A user or a coding agent that reads the error cannot find the page that explains the option.

The error appears in three places:

  • a trigger wired to an undecorated method (on_click=State.helper, a lambda, or a list): EventHandlerValueError
  • app.add_page(..., on_load=State.helper): EventHandlerValueError
  • a handler that returns or yields an undecorated method: TypeError from the event processor

All three end with the shared hint _UNDECORATED_STATE_METHOD_HINT in reflex_base/event/__init__.py.

Proposed change

  1. Add a ## Explicit Event Handlers heading above the state_explicit_event_handlers text in docs/events/events_overview.md, so the section has a stable anchor (#explicit-event-handlers).
  2. End the shared hint with See https://reflex.dev/docs/events/events-overview/#explicit-event-handlers. This follows the existing See https://reflex.dev/docs/... style of other Reflex errors.
  3. Extend the tests for the on_load error and the returned-method error to assert the link.

The change is small: 3 files, plus the 2 test assertions.

Depends on

#7033 must merge first: it adds the option, the hint, and the docs text.

Ngôn ngữ chính
Python
Star
29k
Fork
1.8k
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
154

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 reflex-dev/reflex

Tất cả issue của reflex-dev/reflex

Issue tương tự

Thêm issue về Python

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.