Skip to content

Commit

Permalink
Fix Next.js Pages Router pathname in AppProvider (#4657)
Browse files Browse the repository at this point in the history
  • Loading branch information
apedroferreira authored Feb 4, 2025
1 parent 3eaae57 commit 3a3821f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/toolpad-core/src/nextjs/NextAppProviderPages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { AppProviderProps, Navigate, Router } from '../AppProvider';
* @ignore - internal component.
*/
export function NextAppProviderPages(props: AppProviderProps) {
const { push, replace, asPath, query } = useRouter();
const { push, replace, pathname, query } = useRouter();

const search = React.useMemo(() => {
const params = new URLSearchParams();
Expand Down Expand Up @@ -38,11 +38,11 @@ export function NextAppProviderPages(props: AppProviderProps) {

const routerImpl = React.useMemo<Router>(
() => ({
pathname: asPath,
pathname,
searchParams,
navigate,
}),
[asPath, navigate, searchParams],
[navigate, pathname, searchParams],
);

return <AppProvider router={routerImpl} {...props} />;
Expand Down
2 changes: 1 addition & 1 deletion playground/nextjs-pages/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
2 changes: 1 addition & 1 deletion playground/nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 comments on commit 3a3821f

Please sign in to comment.