This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createCtx<StateType, ActionType>( | |
reducer: React.Reducer<StateType, ActionType>, | |
initialState: StateType, | |
) { | |
const defaultDispatch: React.Dispatch<ActionType> = () => initialState // we never actually use this | |
const ctx = React.createContext({ | |
state: initialState, | |
dispatch: defaultDispatch, // just to mock out the dispatch type and make it not optioanl | |
}) | |
function Provider(props: React.PropsWithChildren<{}>) { |