Add state management
This commit is contained in:
parent
92ca49ab9a
commit
d6942bffab
17 changed files with 340 additions and 133 deletions
16
src/state/models/root-store.ts
Normal file
16
src/state/models/root-store.ts
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue