next.js
d2548b54 - fix router revalidation behavior for dynamic interception routes (#63768)

Commit
2 years ago
fix router revalidation behavior for dynamic interception routes (#63768) ### What When calling `revalidatePath` or `revalidateTag` in a server action for an intercepted route with dynamic segments, the page would do a full browser refresh. ### Why When constructing rewrites for interception routes, the route params leading up to the interception route are "voided" with a `__NEXT_EMPTY_PARAM__` demarcation. When it comes time to look up the values for these dynamic segments, since the params aren't going to be part of the URL, they get matched via `FlightRouterState` ([ref](https://github.com/vercel/next.js/blob/d67d658ce7396c4b6be1b724be5f45763d5a1803/packages/next/src/server/app-render/app-render.tsx#L153-L201)). The `shouldProvideFlightRouterState` variable only passes it through for RSC requests; however, since the server action will perform the action & return the flight data in a single pass, that means the updated tree from the server action isn't going to receive the `FlightRouterState` when constructing the new tree. This means the old tree will have a `["locale", "en", "d"]` segment, and the new tree from the server action will have `"[locale]"`. When the router detects this kind of segment mismatch, it assumes the user navigated to a new root layout, and triggers an MPA navigation. ### How This unconditionally provides the `FlightRouterState` to `makeGetDynamicParamFromSegment` so that it can properly extract dynamic params for interception routes. We currently enforce interception routes to be dynamic due to this `FlightRouterState` dependency. Fixes #59796 Closes NEXT-2079
Author
Parents
Loading