Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks
codeZoon opened this issue Mar 30, 2023 · 8 comments
Open
3 tasks

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

codeZoon opened this issue Mar 30, 2023 · 8 comments

Comments

@codeZoon
Copy link

codeZoon commented Mar 30, 2023

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.
@codeZoon
Copy link
Author

1680140646373

@codeZoon
Copy link
Author

1680141362810

@cristiancananau
Copy link

have the same Issue. Is there any solution ?

@weier910
Copy link

weier910 commented Aug 23, 2023 via email

@ahovbok
Copy link

ahovbok commented Sep 13, 2023

@codeZoon and @cananaucristian, you could downgrade to version 4.0.2. I just checked, and dynamic module registration works fine on this version.

@cristiancananau
Copy link

@ahovbok thank you, i have done that already but i want the issue to be fixed and i want to know why is that not working.

@wolf991
Copy link

wolf991 commented Sep 20, 2023

I think i have a similar problem, not sure, since it's in a big project, and I haven't really bothered to reproduce it in a smaller scale. A workaround i found that works for my scenario, is to use a function in the getter then it works. Again, not sure, if it's the same issue. And even if the workaround works, it would be nice if this would be fixed.

@Super-Chama
Copy link

I'm facing the same issue in 4.1.0 but in my project this happens randomly so its much annoying. hopefully we'll get a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants