Open
Description
Reproduction
https://stackblitz.com/edit/github-5ayhfs4m?file=src%2FApp.vue
Steps to reproduce the bug
- Define a shallowRef state (e.g.
const counter = shallowRef({ count: 0 })
) using setup stores syntax - Use the store in a Vue component
- Update the state using
$patch({ counter: { count: 1 })
syntax - The state is updated in store but the reactivity is not triggered
Expected behavior
At step 4, the Vue's reactivity system should trigger
Actual behavior
At step 4, the Vue's reactivity system does not trigger (no watcher/computed run after the state change)
Additional information
In the playground, I tested with two other ways to update the shallowRef's state, and the reactivity still works normally:
const counterStore = useCounterStore();
// Using $patch with update function: trigger reactivity
counterStore.$patch((state) => {
state.counter2 = { count: state.counter2.count + 1 };
});
// Direct mutate the state: trigger reactivity
counterStore.counter3 = { count: ... };
Activity