Skip to content

button on_click problem #3631

Answered by masenf
w1249841003 asked this question in Q&A
Jul 8, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

When rendering an input in a foreach, you should pass the key prop:

lambda key, value:rx.input(default_value=key.to(str), name='name', key=key.to(str))

Adding the key prop to the rx.input will cause it to be re-rendered whenever the key changes. Otherwise the React javascript framework tries to optimize the DOM updates and won't re-create the input box with the new default_value, and default_value is only ever set once, when the component is created.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@w1249841003
Comment options

Answer selected by w1249841003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants