easy-peasy
easy-peasy copied to clipboard
Allow lodash-style string notation to select state and actions
This PR aims to allow the use of lodash-style get path notation to access state and actions.
e.g.
const store = createStore({
user: {
name: 'John',
change: action((state, payload) => { state.name = payload; })
}
});
Earlier
function App() {
const name = useStoreState(state => state.user.name);
const change = useStoreActions(state => state.user.change);
}
Now
function App() {
const name = useStoreState('user.name');
const change = useStoreActions('user.change');
}
This is meant for just convenience and nothing else.