Skip to content

Changing a local atom not reflected in UI #270

Answered by Gregg8
adwelly asked this question in Q&A
Discussion options

You must be logged in to vote

The input-text component takes the :model you pass it (can be a value or an atom) and copies the value into its own internal atom and uses that from then on.

The value it returns to the :on-change event is the new value of its internal atom. It does not change your atom in any way.

This allows you to have full control of what goes into your atom. It also means you have to reset! your atom to the new value for the change to take effect.

So, simply add a (reset! text-model %) inside the :on-change function and it should do what you want.

For further clarity (I hope), the reason it works the first time is because the Clear button DOES reset! YOUR atom, but your atom then remains empty after …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by superstructor
Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #26 on March 29, 2021 08:48.