Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memoize useRouter from next/navigation when used in Pages Router (#52177
) ## What? Ensures the router instance passed for `next/navigation` in Pages Router is a stable reference. For App Router the router instance is already a stable reference, so making this one stable too would fix #18127. ## How? Added `React.useMemo` around `adaptForAppRouterInstance`, previously it was recreated each render but that's not needed for this particular case. The searchParamsContext and pathnameContext do need a new value each render in order to ensure they get the latest value. Fixes #18127 Fixes NEXT-1375
- Loading branch information