Skip to content

Getters - Reactivity broken after registering new module #2197

@lordolive

Description

@lordolive

Version

Vue: 3.2.45
Vuex: 4.1.0

Reproduction link

https://github.com/lordolive/vuex4-getters-reactivity

Steps to reproduce

  • Clone the repo
  • npm i
  • npm run dev

Then in website :

  • Click the first button, the getter is reactive and the count increments.
  • Click the second button to register the module
  • Click the first button, the getter is no longer reactive and the count does not change.

What is expected?

The getter reactivity should still work and the count in the button should increment.

What is actually happening?

The getter accessed before the call to this.$store.registerModule() is no longer reactive, but the one that was not accessed before is still reactive

image

Additionnal comments

I first tried with MapGetters and had the same problem.
Using $store.getters.count directly in the template solve the issue, but in my real application with multiple modules it is simply not pratical, especially considering that we are migrating a lot of code from Vue 2 which was working with mapGetters.

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