about summary refs log tree commit diff
path: root/src/state/models/root-store.ts
blob: 164dfcced60ad9d950c030bc99371dc61f5fbd22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)