next.js
ae3db7ce - Memoize useRouter from next/navigation when used in Pages Router (#52177)

Commit
2 years ago
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
Author
Parents
Loading