button on_click problem #3631
Answered
by
masenf
w1249841003
asked this question in
Q&A
-
After I clicked edit, the input displayed the previous value
How should I deal with this problem? Thank you |
Beta Was this translation helpful? Give feedback.
Answered by
masenf
Jul 8, 2024
Replies: 1 comment 1 reply
-
When rendering an input in a foreach, you should pass the lambda key, value:rx.input(default_value=key.to(str), name='name', key=key.to(str)) Adding the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
w1249841003
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When rendering an input in a foreach, you should pass the
key
prop:Adding the
key
prop to therx.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.