CodexBloom - Programming Q&A Platform

Vue component not re-rendering after updating reactive property with a mutation in Vuex

πŸ‘€ Views: 393 πŸ’¬ Answers: 1 πŸ“… Created: 2025-07-27
vue vuex reactivity JavaScript

I'm having trouble with I'm integrating two systems and I'm working with an scenario where my Vue component isn't re-rendering after I update a reactive property in my Vuex store using a mutation. I've confirmed that the mutation is firing correctly, and the state is indeed changing, but the component isn't reflecting the updated state. Here’s a simplified version of my code: ```javascript // store.js const store = new Vuex.Store({ state: { count: 0 }, mutations: { increment(state) { state.count++; } } }); // MyComponent.vue <template> <div> <p>Count: {{ count }}</p> <button @click="incrementCount">Increment</button> </div> </template> <script> export default { computed: { count() { return this.$store.state.count; } }, methods: { incrementCount() { this.$store.commit('increment'); } } }; </script> ``` I've tried using `mapState` from `vuex` to bind the state, but it didn't change anything. I'm also sure that my Vuex store is properly integrated with my Vue instance. I expected the count to update in the component when I click the button, but it remains unchanged. In the console, I can see that the mutation is logged as executed, but the view stays stale. I’m using Vue 2.6.14 and Vuex 3.6.2. Is there something I'm missing or any specific configuration required to ensure the component reacts to state changes? Thanks for taking the time to read this! For context: I'm using Javascript on Linux. Any suggestions would be helpful.