Add Keys() and Values() for dict-type vars ? #3027
yellowbean
announced in
Ideas
Replies: 1 comment
-
Currently you can do this with normal foreach and a lambda: class State(rx.State):
my_d: dict[str, str] = {"a": "1", "b": "2", "c": "3"}
def index() -> rx.Component:
return rx.vstack(
rx.foreach(
State.my_d,
lambda kv: rx.hstack(
rx.heading(kv[0])
),
)
) But i agree, it might be more clear to have |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
There are couple useful operators for vars
https://reflex.dev/docs/vars/var-operations/
Since it's quite common to have
dict
type as vars ,myDict: dict[str,int]
do you think it would be great to have Keys() or Values() on the
myDict
?then equivalent to
If there is a lot of vars like
myDict
, then the code just will have unnecessary lines.Expected behavior
In the component
Beta Was this translation helpful? Give feedback.
All reactions