fix: use rx.Var.create to get a str var#1684
Merged
carlosabadia merged 1 commit intoreflex-dev:mainfrom Nov 5, 2025
macmoritz:fix-local-packages-example-rx-var
Merged
fix: use rx.Var.create to get a str var#1684carlosabadia merged 1 commit intoreflex-dev:mainfrom macmoritz:fix-local-packages-example-rx-var
carlosabadia merged 1 commit intoreflex-dev:mainfrom
macmoritz:fix-local-packages-example-rx-var
Conversation
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Fixed a documentation example that incorrectly used rx.Var("World") to set a default string value for a component field. Changed to rx.Var.create("World") to ensure proper string quoting in the generated frontend code.
Key Changes:
- Updated
docs/wrapping-react/local-packages.md:74fromrx.Var("World")torx.Var.create("World") - This aligns with the established pattern used in other components (
pcweb/components/number_flow.py,pcweb/components/marquee.py)
Related Concerns:
The PR description mentions additional occurrences of rx.Var("...") in other files that may have similar issues:
pcweb/components/hosting_banner.py:40- usesrx.Var("t").to(str)in a function contextpcweb/pages/hosting_countdown/timer.py:8- usesrx.Var("t").to(str)in a function contextdocs/api-reference/var_system.md:49- usesrx.Var("2", _var_type=int)as a documentation example for raw JavaScript stringsdocs/enterprise/react_flow/nodes.md:243,246- usesrx.Var("node").to(Node)in function contexts
These other occurrences appear to be used in different contexts (function arguments for ArgsFunctionOperation.create) where rx.Var() might be intentionally creating raw JavaScript variable references rather than string literals. However, they warrant separate investigation to confirm they work as intended.
Confidence Score: 5/5
- This PR is safe to merge - it fixes a legitimate bug in documentation example code
- The change correctly fixes a documentation example by following the established pattern used throughout the codebase for setting default string values on Var fields. The fix is minimal (one line), well-understood, and aligns with existing best practices in the codebase.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| docs/wrapping-react/local-packages.md | 5/5 | Changed rx.Var("World") to rx.Var.create("World") to fix frontend rendering issue where strings were not properly quoted |
Sequence Diagram
sequenceDiagram
participant Dev as Developer
participant Comp as Hello Component
participant Reflex as Reflex Framework
participant Frontend as Frontend/Browser
Dev->>Comp: Define name field with default value
Note over Comp: Before: rx.Var("World")<br/>After: rx.Var.create("World")
Comp->>Reflex: Register component with Var field
alt Using rx.Var("World") [Before Fix]
Reflex->>Frontend: Renders as: World (no quotes)
Frontend->>Frontend: Parse error: expected string
Note over Frontend: Frontend cannot handle<br/>unquoted literal
end
alt Using rx.Var.create("World") [After Fix]
Reflex->>Frontend: Renders as: "World" (quoted string)
Frontend->>Frontend: Successfully parses string value
Note over Frontend: Frontend correctly interprets<br/>quoted string literal
end
1 file reviewed, no comments
carlosabadia
approved these changes
Nov 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
rx.Var("Hello")this is rendered toHellowithout quotes, so no string. Therefor the frontend can not handle this.With the help of @benedikt-bartscher this was quickly solved by using
rx.Var.create("Hello").There are more occurences, which might be failing too: