openhands / src /context /navigation-context.tsx
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
5f40163 verified
Raw History Blame Contribute Delete
852 Bytes
import React from "react";
export interface NavigationOptions {
replace?: boolean;
}
export interface NavigationContextValue {
currentPath: string;
conversationId: string | null;
isNavigating: boolean;
navigate: (to: string, options?: NavigationOptions) => void;
}
const noop = () => {};
const NavigationContext = React.createContext<NavigationContextValue>({
currentPath: "/",
conversationId: null,
isNavigating: false,
navigate: noop,
});
interface NavigationProviderProps {
value: NavigationContextValue;
children: React.ReactNode;
}
export function NavigationProvider({
value,
children,
}: NavigationProviderProps) {
return (
<NavigationContext.Provider value={value}>
{children}
</NavigationContext.Provider>
);
}
export function useNavigation() {
return React.useContext(NavigationContext);
}