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

Idea: Pass state to actions context #11

Closed
l-portet opened this issue Jun 30, 2022 · 1 comment
Closed

Idea: Pass state to actions context #11

l-portet opened this issue Jun 30, 2022 · 1 comment

Comments

@l-portet
Copy link

Another idea that would be useful to me is to access the state inside an action context.

Example:

// store.js
const store = {
  state: { count: 0 },
  mutations: {
    SET_COUNT(state, value) {
      state.count = value;
    }
  },
  actions: {
    increment(context) { // context only contains actions and mutations
      context.mutations.SET_COUNT(context.state.count + 1);
    }
  }
}

Idk if it's possible though, as you mentioned the way the state is written is not really reactive.

@DJanoskova
Copy link
Owner

Hi @l-portet ,
Sorry for the late reply, I had another state management lib in progress! That one led me to using React's useSyncExternalStore and this allowed a complete upgrade for vuex-but-for-react to a 3.0.0 version that does support state in actions context 🎉

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

2 participants