Skip to content

Instantly share code, notes, and snippets.

@hasparus
Created May 19, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasparus/8124e5bbe1f3c5cb61d06ed29b9f56a3 to your computer and use it in GitHub Desktop.
Save hasparus/8124e5bbe1f3c5cb61d06ed29b9f56a3 to your computer and use it in GitHub Desktop.
Infer the type zustand store state
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