Created
May 19, 2019 13:08
-
-
Save hasparus/8124e5bbe1f3c5cb61d06ed29b9f56a3 to your computer and use it in GitHub Desktop.
Infer the type zustand store state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createStore from 'zustand'; | |
export const [useStore, _store] = createStore(set => ({ | |
foo: 2, | |
actions: { | |
setFoo: (newFoo: number) => { | |
set({ foo: newFoo }); | |
}, | |
}, | |
})); | |
export type State = ReturnType<typeof _store.getState>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment