mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
27 lines
574 B
TypeScript
27 lines
574 B
TypeScript
import {createContext, useContext} from 'react';
|
|
|
|
interface RoutingContextValue {
|
|
baseURL: string;
|
|
}
|
|
|
|
const DEFAULT_VALUE = {
|
|
baseURL: '/starfish',
|
|
};
|
|
|
|
const RoutingContext = createContext<RoutingContextValue>(DEFAULT_VALUE);
|
|
|
|
interface Props {
|
|
children: React.ReactNode;
|
|
value?: RoutingContextValue;
|
|
}
|
|
|
|
export const useRoutingContext = () => useContext(RoutingContext);
|
|
|
|
export function RoutingContextProvider({value, children}: Props) {
|
|
return (
|
|
<RoutingContext.Provider value={value ?? DEFAULT_VALUE}>
|
|
{children}
|
|
</RoutingContext.Provider>
|
|
);
|
|
}
|