Skip to content

docs: events, storage, and component field notes#6779

Open
amsraman wants to merge 1 commit into
mainfrom
docs/events-storage-field-notes
Open

docs: events, storage, and component field notes#6779
amsraman wants to merge 1 commit into
mainfrom
docs/events-storage-field-notes

Conversation

@amsraman

Copy link
Copy Markdown
Contributor

Fourth batch of upstreaming Reflex Build's AI-builder knowledge base (#6775, #6777, and the recharts batch). Events/storage/component gaps:

  • event_triggers: on_key_down/on_key_up sections (keyboard triggers were previously undocumented) and a Global Keyboard Events section for rx.window_event_listener (also undocumented)
  • memo: Using with rx.foreach (lambda + keyword args; the key prop forwarding β€” verified against reflex_base source)
  • text_area: Submitting on Enter (enter_key_submit, Shift+Enter behavior, and a verified warning that it can't be combined with on_key_down β€” raises ValueError)
  • special_events: set_clipboard with state Vars, backend rx.download(data=...) example, auto_scroll cross-link
  • page_load_events: loading/error handling pattern (yield-for-immediate-loading-state, try/except/finally)
  • browser_storage: local-storage positional-default callout

Notably, three knowledge-base claims were checked against source and rejected rather than upstreamed (rx.get_clipboard doesn't exist; .temporal doesn't guarantee ordering; sync isn't default-on). Pre-commit clean.

πŸ€– Generated with Claude Code

Keyboard event triggers (on_key_down/on_key_up) and global hotkeys via
rx.window_event_listener (previously undocumented), memo-with-foreach
patterns, enter_key_submit with its on_key_down conflict, set_clipboard
with state vars, backend rx.download, on_load loading/error handling,
and a local-storage positional-default note. Three stale knowledge-base
claims were verified against source and rejected rather than upstreamed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amsraman amsraman requested review from a team and Alek99 as code owners July 15, 2026 23:06
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

βœ… 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing docs/events-storage-field-notes (96b2fe3) with main (65a2889)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (127e4d8) during the generation of this report, so 65a2889 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR upstreams documentation from Reflex Build's AI-builder knowledge base, filling gaps across six doc files covering keyboard event triggers, memoized components with rx.foreach, textarea enter-key submission, special events (rx.set_clipboard with Vars, rx.download with data), page-load error handling, and a browser storage positional-argument callout. All technical claims were cross-checked against source; three knowledge-base items were correctly rejected rather than upstreamed.

  • event_triggers.md: Adds on_key_down / on_key_up sections and a Global Keyboard Events section using rx.window_event_listener; verified against window_events.py.
  • text_area.md: Documents enter_key_submit and the ValueError raised when combined with on_key_down; confirmed in forms.py.
  • memo.md: Adds a rx.foreach + @rx.memo + key prop example that, per memo.py, triggers a console.deprecate warning (since 0.9.3, removal in 1.0) β€” the example should use rx.RestProp or at minimum disclose the deprecation.

Confidence Score: 4/5

Five of the six files are accurate, well-verified additions; the memo.md change documents a deprecated pattern as if it is recommended.

The rx.foreach + @rx.memo + key example teaches a usage pattern that emits a framework deprecation warning today and will silently break when 1.0 removes it. Every other addition in the PR was checked against source and is correct. The memo fix is isolated to one example and has a clear remediation (add rx.RestProp).

docs/library/other/memo.md β€” the new rx.foreach section's key forwarding pattern conflicts with the deprecation introduced in 0.9.3.

Important Files Changed

Filename Overview
docs/library/other/memo.md New "Using with rx.foreach" section documents passing key= to a memo without rx.RestProp, which triggers a deprecation warning in 0.9.3 and will be removed in 1.0; otherwise the section is accurate.
docs/api-reference/event_triggers.md Adds on_key_down / on_key_up sections and a Global Keyboard Events section using rx.window_event_listener; all claims verified against source.
docs/api-reference/browser_storage.md Adds info callout clarifying that the default value is the first positional argument; verified against reflex/istate/storage.py positional-only object param.
docs/api-reference/special_events.md Adds cross-link to rx.auto_scroll, a rx.set_clipboard Var example, and a rx.download(data=...) example; all are accurate.
docs/events/page_load_events.md Adds loading/error handling pattern with yield-for-immediate-state, try/except/finally; content is accurate and helpful.
docs/library/forms/text_area.md Adds "Submitting on Enter" section with enter_key_submit prop; verified against source that combining with on_key_down raises ValueError.

Reviews (1): Last reviewed commit: "docs: events, storage, and component fie..." | Re-trigger Greptile

Comment on lines +74 to +107
lambda and pass the props by keyword. Also pass a `key` prop that uniquely
identifies each item β€” React uses it to track items across re-renders β€” but do
**not** declare `key` in the memo function's signature. It is forwarded
automatically and consumed by React.

```python
from typing import TypedDict


class Task(TypedDict):
id: str
name: str


class TaskState(rx.State):
tasks: list[Task] = [
{"id": "1", "name": "Write docs"},
{"id": "2", "name": "Review PR"},
]


@rx.memo
def task_card(task: rx.Var[Task]) -> rx.Component:
return rx.card(rx.text(task["name"]))


def index():
return rx.vstack(
rx.foreach(
TaskState.tasks,
lambda task: task_card(task=task, key=task["id"]),
),
)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Deprecated key forwarding pattern documented as recommended

The example passes key=task["id"] to task_card which has no rx.RestProp parameter. In packages/reflex-base/src/reflex_base/components/memo.py (lines 1630–1643), this path hits _warn_legacy_base_props, emitting a console.deprecate call with deprecation_version="0.9.3" and removal_version="1.0". The deprecation message explicitly tells users to "Declare an rx.RestProp parameter to keep passing base props like key". Any user who follows this doc example as written will see a deprecation warning on every render, and the pattern will stop working entirely in 1.0.

The example should add rest: rx.RestProp to task_card's signature so the key is forwarded through the ...rest spread without triggering the warning, or at minimum include a note that this usage is deprecated and show the rx.RestProp alternative.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96b2fe3316

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".



@rx.memo
def task_card(task: rx.Var[Task]) -> rx.Component:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid documenting deprecated key forwarding

When users copy this rx.foreach example, the later key=... is passed to a memo that has no rx.RestProp. The runtime explicitly treats that as legacy and calls _warn_legacy_base_props when rest_param is None (packages/reflex-base/src/reflex_base/components/memo.py:1630-1643), with the deprecation message saying to declare rx.RestProp for base props (packages/reflex-base/src/reflex_base/components/memo.py:1869-1878). This doc therefore recommends a pattern that immediately emits a deprecation warning and is scheduled for removal; include and pass a RestProp while still not declaring key as an explicit prop, or call out the warning.

Useful? React with πŸ‘Β / πŸ‘Ž.

Comment on lines +136 to +139
The `enter_key_submit` prop is implemented with its own key down handler, so
passing both to the same component raises an error. If custom key handling is
needed, implement the Enter-to-submit behavior in your own `on_key_down`
handler instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't suggest on_key_down can replace enter_key_submit

In the case where a textarea also needs custom key handling, this fallback tells users to implement the Enter-submit behavior with a normal Reflex on_key_down, but the built-in implementation needs the raw JS event to call e.preventDefault() and e.target.form.requestSubmit() (packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py:870-877), while the public key event only sends the key and modifier Vars to state handlers (packages/reflex-base/src/reflex_base/event/__init__.py:1028-1045). Following this advice still lets Enter insert a newline, and using .prevent_default would suppress all key input rather than only Enter, so the docs should point to a custom JS custom_attrs handler or another supported pattern.

Useful? React with πŸ‘Β / πŸ‘Ž.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant