mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 22:40:50 +01:00
21 lines
682 B
TypeScript
21 lines
682 B
TypeScript
import { createContext, Dispatch, FC, ProviderProps, useContext } from 'react';
|
|
import { INavigatorAction, INavigatorState } from './reducers/NavigatorReducer';
|
|
|
|
interface INavigatorContext
|
|
{
|
|
navigatorState: INavigatorState;
|
|
dispatchNavigatorState: Dispatch<INavigatorAction>;
|
|
}
|
|
|
|
const NavigatorContext = createContext<INavigatorContext>({
|
|
navigatorState: null,
|
|
dispatchNavigatorState: null
|
|
});
|
|
|
|
export const NavigatorContextProvider: FC<ProviderProps<INavigatorContext>> = props =>
|
|
{
|
|
return <NavigatorContext.Provider value={ props.value }>{ props.children }</NavigatorContext.Provider>
|
|
}
|
|
|
|
export const useNavigatorContext = () => useContext(NavigatorContext);
|