mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Next.js: Support v15.1
This commit is contained in:
parent
b6a1547dd5
commit
fa46d28f93
@ -44,8 +44,6 @@ function getSelectedParams(currentTree: FlightRouterState, params: Params = {}):
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ensure catchAll and optional catchall are turned into an array
|
||||
|
||||
// Ensure catchAll and optional catchall are turned into an array
|
||||
const isCatchAll = isDynamicParameter && (segment[2] === 'c' || segment[2] === 'oc');
|
||||
|
||||
@ -82,6 +80,16 @@ export const AppRouterProvider: React.FC<React.PropsWithChildren<AppRouterProvid
|
||||
return getSelectedParams(tree);
|
||||
}, [tree]);
|
||||
|
||||
const newLazyCacheNode = {
|
||||
lazyData: null,
|
||||
rsc: null,
|
||||
prefetchRsc: null,
|
||||
head: null,
|
||||
prefetchHead: null,
|
||||
parallelRoutes: new Map(),
|
||||
loading: null,
|
||||
};
|
||||
|
||||
// https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/app-router.tsx#L436
|
||||
return (
|
||||
<PathParamsContext.Provider value={pathParams}>
|
||||
@ -106,10 +114,18 @@ export const AppRouterProvider: React.FC<React.PropsWithChildren<AppRouterProvid
|
||||
<AppRouterContext.Provider value={getRouter()}>
|
||||
<LayoutRouterContext.Provider
|
||||
value={{
|
||||
// TODO Remove when dropping Next.js < v15.1.1
|
||||
childNodes: new Map(),
|
||||
loading: null,
|
||||
tree,
|
||||
// TODO END
|
||||
|
||||
// START Next.js v15.2 support
|
||||
// @ts-expect-error Only available in Next.js >= v15.1.1
|
||||
parentTree: tree,
|
||||
parentCacheNode: newLazyCacheNode,
|
||||
// END
|
||||
url: pathname,
|
||||
loading: null,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
@ -80,6 +80,16 @@ export const AppRouterProvider: React.FC<React.PropsWithChildren<AppRouterProvid
|
||||
return getSelectedParams(tree);
|
||||
}, [tree]);
|
||||
|
||||
const newLazyCacheNode = {
|
||||
lazyData: null,
|
||||
rsc: null,
|
||||
prefetchRsc: null,
|
||||
head: null,
|
||||
prefetchHead: null,
|
||||
parallelRoutes: new Map(),
|
||||
loading: null,
|
||||
};
|
||||
|
||||
// https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/app-router.tsx#L436
|
||||
return (
|
||||
<PathParamsContext.Provider value={pathParams}>
|
||||
@ -104,8 +114,16 @@ export const AppRouterProvider: React.FC<React.PropsWithChildren<AppRouterProvid
|
||||
<AppRouterContext.Provider value={getRouter()}>
|
||||
<LayoutRouterContext.Provider
|
||||
value={{
|
||||
// TODO Remove when dropping Next.js < v15.1.1
|
||||
childNodes: new Map(),
|
||||
tree,
|
||||
// TODO END
|
||||
|
||||
// START Next.js v15.2 support
|
||||
// @ts-expect-error Only available in Next.js >= v15.1.1
|
||||
parentTree: tree,
|
||||
parentCacheNode: newLazyCacheNode,
|
||||
// END
|
||||
url: pathname,
|
||||
loading: null,
|
||||
}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user