nitro-react/src/components/navigator/NavigatorContext.tsx

21 lines
682 B
TypeScript
Raw Normal View History

2021-12-13 06:43:04 +01:00
import { createContext, Dispatch, FC, ProviderProps, useContext } from 'react';
2022-03-02 00:00:04 +01:00
import { INavigatorAction, INavigatorState } from './reducers/NavigatorReducer';
2021-12-13 06:43:04 +01:00
2022-03-02 00:00:04 +01:00
interface INavigatorContext
2021-12-13 06:43:04 +01:00
{
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);