UNPKG

@etsoo/toolpad

Version:

Dashboard framework extention based on Toolpad Core

28 lines (27 loc) 1 kB
import { jsx as _jsx } from "react/jsx-runtime"; import * as React from "react"; import { usePathname, useSearchParams, useRouter } from "next/navigation"; import { AppProvider } from "../AppProvider/AppProviderComponent"; /** * @ignore - internal component. */ export function AppProviderNextApp(props) { const pathname = usePathname(); const searchParams = useSearchParams(); const { push, replace } = useRouter(); const navigate = React.useCallback((url, { history = "auto" } = {}) => { if (history === "auto" || history === "push") { return push(String(url)); } if (history === "replace") { return replace(String(url)); } throw new Error(`Invalid history option: ${history}`); }, [push, replace]); const routerImpl = React.useMemo(() => ({ pathname, searchParams, navigate }), [pathname, navigate, searchParams]); return _jsx(AppProvider, { router: routerImpl, ...props }); }