Skip to content

Instantly share code, notes, and snippets.

@reime005
Created January 23, 2021 00:55
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 reime005/03e8316ade92ddbe6dc278112cca440e to your computer and use it in GitHub Desktop.
Save reime005/03e8316ade92ddbe6dc278112cca440e to your computer and use it in GitHub Desktop.
// config.ts
export const setupStore = async (): Promise<Store> => {
// we could perform asynchronously loading operations here
return initialStore;
};
const RootStoreContext = React.createContext<Store>(initialStore);
/**
* The provider to expose the root store
*/
export const RootStoreProvider = RootStoreContext.Provider;
export const useConfig = () => React.useContext(RootStoreContext).config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment