Reactivity not triggered when setting state to the same value #12100
Unanswered
Gonzalo-Bruna
asked this question in
Help/Questions
Replies: 2 comments
-
Vue's Reactivity is based on state changes. When state doesn't change, there seems to be no need for updates of effects, so Vue skips them. That's kind of a core assuption. In edge cases like this one, you can use |
Beta Was this translation helpful? Give feedback.
0 replies
-
In this scenario, I would use the |
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
-
Issue Description
I'm encountering a situation where Vue's reactivity system doesn't trigger an update when setting a state value to the same value it currently holds. This becomes problematic in scenarios where we need to ensure the UI reflects the current state, even if it hasn't changed.
Example
Consider this simplified component:
Current Behavior
updateQuantity
function setsquantity.value
back to 1.Expected Behavior
The input should show "1" again after step 3, reflecting the current state of
quantity
.Workaround
I've found a workaround by forcing a state change before setting the actual value:
While this works, it feels like a hack. Is there a more idiomatic way to handle this scenario in Vue 3?
Environment
Beta Was this translation helpful? Give feedback.
All reactions