Add a docs link to the state_explicit_event_handlers error hint

未关闭 适合新手
#7,915 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

阅读 docs/events/events_overview.md 和 reflex_base/event/__init__.py 中共享的 _UNDECORATED_STATE_METHOD_HINT,然后找到 on_load 和返回方法的测试。添加 issue 中描述的稳定标题和文档链接,并扩展两个测试的断言以检查该链接。完成标准是三个错误路径都使用带链接的相同提示,并且两个测试都断言该提示。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
29k
派生
1.8k
平均合并
2 天 22 小时
30 天内合并 PR
154

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

reflex-dev/reflex 的其他 Issue

查看 reflex-dev/reflex 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。