Skip to content
Discussion options

You must be logged in to vote

You need to put the useStore() within the other store, not outside:

import { useBStore } from './b';
// cannot call useBStore() here
export const useAStore = defineStore('a', {
  state: () => {
    return {
      a: 22,
    };
  },
  actions: {
    increaseA() {
      this.a++;
// it must be here
      const bStore = useBStore();

      bStore.decrease();
    },
  },
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@maicWorkGithub
Comment options

@posva
Comment options

@maicWorkGithub
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2135 on April 12, 2023 11:54.