react-code-dataset / next.js /packages /next /src /client /components /router-reducer /handle-segment-mismatch.ts
Download next.js/packages/next/src/client/components/router-reducer/handle-segment-mismatch.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/client/components/router-reducer/handle-segment-mismatch.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/client/components/router-reducer/handle-segment-mismatch.ts
-
curl -L -o handle-segment-mismatch.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/client/components/router-reducer/handle-segment-mismatch.ts
1.06 kB
| import type { FlightRouterState } from '../../../server/app-render/types' | |
| import { handleExternalUrl } from './reducers/navigate-reducer' | |
| import type { | |
| ReadonlyReducerState, | |
| ReducerActions, | |
| } from './router-reducer-types' | |
| /** | |
| * Handles the case where the client router attempted to patch the tree but, due to a mismatch, the patch failed. | |
| * This will perform an MPA navigation to return the router to a valid state. | |
| */ | |
| export function handleSegmentMismatch( | |
| state: ReadonlyReducerState, | |
| action: ReducerActions, | |
| treePatch: FlightRouterState | |
| ) { | |
| if (process.env.NODE_ENV === 'development') { | |
| console.warn( | |
| 'Performing hard navigation because your application experienced an unrecoverable error. If this keeps occurring, please file a Next.js issue.\n\n' + | |
| 'Reason: Segment mismatch\n' + | |
| `Last Action: ${action.type}\n\n` + | |
| `Current Tree: ${JSON.stringify(state.tree)}\n\n` + | |
| `Tree Patch Payload: ${JSON.stringify(treePatch)}` | |
| ) | |
| } | |
| return handleExternalUrl(state, {}, state.canonicalUrl, true) | |
| } | |