You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes a ReferenceError: pyOr is not defined that occurred when rx.match was used with multiple patterns per case. The root cause was that _cached_var_name in LiteralComponentVar calls str() on the result of render_dict_to_var, discarding any VarData (including import requirements) accumulated during expression construction.
Bug fix: _PY_OR_IMPORT is now unconditionally added to the merged VarData of every LiteralComponentVar to guarantee pyOr is always available in the compiled output. The developer explicitly notes a cleaner long-term alternative (propagating VarData out of render_dict_to_var) as a follow-up.
Refactor: The per-case OR-chaining logic is extracted into _format_patterns_into_condition, which also eliminates the previous Var.create(False) seed that caused an unnecessary pyOr(False, () => (...)) wrapper for single-pattern cases.
Confidence Score: 4/5
The fix is correct and resolves the reported runtime error; the only trade-off is a blanket pyOr import added to every component, which is safe but worth revisiting as a follow-up.
The core bug (missing pyOr import with multi-pattern rx.match) is correctly fixed and well-explained. The workaround unconditionally injects the import for all components — the developer documents this and proposes a cleaner alternative — but the approach introduces a permanent, minor unnecessary import in cases that don't use multi-pattern matching. No data loss or incorrect behavior introduced.
packages/reflex-base/src/reflex_base/components/component.py — specifically the _cached_get_all_var_data workaround and the undocumented _format_patterns_into_condition helper.
Fixes missing pyOr import when rx.match generates OR conditions; extracts pattern-matching logic into a helper function and unconditionally injects the import into all LiteralComponentVar instances as a documented workaround.
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
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.
previously:
now: