-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
First, thanks for the great package :)
What about a hook to access the state directly instead of having to write a specific getter, such as mapState
in VueX?
I find it a bit redundant to write getters for each property of my state.
Example:
// store.js
const store = {
state: { count: 0 },
mutations: {
SET_COUNT(state, value) {
state.count = value;
}
},
actions: {
increment(context) {
context.mutations.SET_COUNT(context.state.count + 1);
}
}
}
import { useStoreState } from 'vuex-but-for-react';
export function Counter() {
const count = useStoreState('count');
// or const count = useStoreState(state => state.count);
return //...
}
Metadata
Metadata
Assignees
Labels
No labels