Add state management

This commit is contained in:
Paul Frazee 2022-06-09 13:03:25 -05:00
parent 92ca49ab9a
commit d6942bffab
17 changed files with 340 additions and 133 deletions

View file

@ -0,0 +1,16 @@
/**
* The root store is the base of all modeled state.
*/
import {Instance, SnapshotOut, types} from 'mobx-state-tree'
import {createContext, useContext} from 'react'
export const RootStoreModel = types.model('RootStore').props({})
export interface RootStore extends Instance<typeof RootStoreModel> {}
export interface RootStoreSnapshot extends SnapshotOut<typeof RootStoreModel> {}
// react context & hook utilities
const RootStoreContext = createContext<RootStore>({} as RootStore)
export const RootStoreProvider = RootStoreContext.Provider
export const useStores = () => useContext(RootStoreContext)