Subscribe on changes!

Reactive behavior is not working properly for Provide + Inject scenario

avatar
Jun 29th 2021

Version

3.0.5

Reproduction link

https://bit.ly/3qyYS8l

Steps to reproduce

Reproduction code is attached in the url

What is expected?

I have a parent and child components. When there is a mutation through a function, and the value is not reflected even if the reactive behavior is enforced. I have attached a sample code in the url.

What is actually happening?

The value should be updated when I press the button


I am not sure whether I have missed out anything.

avatar
Jun 29th 2021

You need to either create a computed or a toRef() out of store.state.value. Otherwise, you are reading the value once. only

const value = toRef(store.state, 'count');
const value = computed(() => store.state.count);

Playground


Remember to use the forum or the Discord chat to ask questions!