Skip to content

Commit af79ef8

Browse files
committed
fix ref
1 parent c759562 commit af79ef8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

reflex/vars/base.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,17 +1135,14 @@ def _as_ref(self) -> Var:
11351135
Returns:
11361136
The reference to the var.
11371137
"""
1138-
from .object import ObjectVar
1139-
1140-
refs = Var(
1141-
_js_expr="refs",
1138+
return Var(
1139+
_js_expr=f"refs[{Var.create(str(self))}]",
11421140
_var_data=VarData(
11431141
imports={
11441142
f"$/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")]
11451143
}
11461144
),
1147-
).to(ObjectVar, Mapping[str, str])
1148-
return refs[LiteralVar.create(str(self))]
1145+
).to(str)
11491146

11501147
def js_type(self) -> StringVar:
11511148
"""Returns the javascript type of the object.

tests/units/test_state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,8 @@ class UnionState(BaseState):
28192819
str(UnionState.c3.c2r.c1.foo) == f'{UnionState.c3!s}?.["c2r"]?.["c1"]?.["foo"]' # pyright: ignore [reportOptionalMemberAccess]
28202820
)
28212821
assert (
2822-
str(UnionState.c3.c2r.c1r.foo) == f'{UnionState.c3!s}?.["c2r"]?.["c1r"]?.["foo"]' # pyright: ignore [reportOptionalMemberAccess]
2822+
str(UnionState.c3.c2r.c1r.foo)
2823+
== f'{UnionState.c3!s}?.["c2r"]?.["c1r"]?.["foo"]' # pyright: ignore [reportOptionalMemberAccess]
28232824
)
28242825
assert str(UnionState.c3i.c2) == f'{UnionState.c3i!s}?.["c2"]'
28252826
assert str(UnionState.c3r.c2) == f'{UnionState.c3r!s}?.["c2"]'

0 commit comments

Comments
 (0)