2021-12-13 06:43:04 +01:00
|
|
|
import { createContext, Dispatch, FC, ProviderProps, useContext } from 'react';
|
|
|
|
import { INavigatorAction, INavigatorState } from '../reducers/NavigatorReducer';
|
|
|
|
|
|
|
|
export interface INavigatorContext
|
|
|
|
{
|
|
|
|
navigatorState: INavigatorState;
|
|
|
|
dispatchNavigatorState: Dispatch<INavigatorAction>;
|
|
|
|
}
|
2021-05-05 00:38:31 +02:00
|
|
|
|
|
|
|
const NavigatorContext = createContext<INavigatorContext>({
|
|
|
|
navigatorState: null,
|
|
|
|
dispatchNavigatorState: null
|
|
|
|
});
|
|
|
|
|
2021-12-13 06:43:04 +01:00
|
|
|
export const NavigatorContextProvider: FC<ProviderProps<INavigatorContext>> = props =>
|
2021-05-05 00:38:31 +02:00
|
|
|
{
|
|
|
|
return <NavigatorContext.Provider value={ props.value }>{ props.children }</NavigatorContext.Provider>
|
|
|
|
}
|
|
|
|
|
|
|
|
export const useNavigatorContext = () => useContext(NavigatorContext);
|