Skip to content

The getter is updated, but the associated dom is not updated. #2217

Description

@codeZoon

Version

"vuex": "^4.1.0"

Describe the bug

After registering the module dynamically, devtool shows that the state and getters are recomputed, but the getter-related views are not updated.

Reproduction

`
/* /src/store/index.ts */
import { createStore } from "vuex";

export const store = createStore({
state() {
return {
count: 0
}
},

getters: {
double(state) {
return state.count * 2;
}
},

mutations: {
increment(state, num) {
state.count += num;
},
decrement(state, num) {
state.count -= num;
}
}
});
`

`
/* /src/main.ts */
import { createApp } from 'vue';
import App from './App.vue';
import { store } from './store';

createApp(App).use(store).mount('#app');
`

`
/* /src/App.vue */

<script setup lang="ts"> import { computed } from '@vue/reactivity'; import { useStore } from 'vuex'; const store = useStore(); const count = computed(() => { return store.state.count; }); const double = computed(() => { return store.getters.double; }); function increment() { store.commit('increment', 1); } function decrement() { store.commit('decrement', 1); } function registerModule(name: string) { const module = { state() { return {} } }; store.registerModule(name, module); } </script>

- count: {{ count }} => double: {{ double }} +

register module

`

Expected behavior

The view associated with the getter should be updated.

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions