-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fallback detection logic when multiple generateStaticParams are n…
…eeded (#47982) ### What? Our current logic of detecting if a route allows dynamic params or not (`fallback`) is flawed, and this PR fixes it. ### Why? Right now, if no `generateStaticParams` is specified we return `fallback: undefined` during dev. However, for an app with multiple params, it may have multiple `generateStaticParams` defined in different levels. If some level isn't covered by any `generateStaticParams`, we still can't determine the fallback value. ### How? I added a naive implementation to check if all params are covered by `generateStaticParams` in the current or inner layers. Closes NEXT-946
- Loading branch information
Showing
5 changed files
with
56 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/app-static/app/flight/[slug]/[slug2]/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { cookies } from 'next/headers' | ||
|
||
import Refresh from './refresh' | ||
|
||
export default function Page() { | ||
const cookieValue = cookies().get('test-cookie') | ||
return ( | ||
<> | ||
<Refresh /> | ||
<h1>{cookieValue?.value}</h1> | ||
</> | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/app-static/app/flight/[slug]/[slug2]/refresh.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use client' | ||
|
||
import { useRouter } from 'next/navigation' | ||
|
||
export default function Refresh() { | ||
const router = useRouter() | ||
|
||
return <button onClick={() => router.refresh()}>Refresh</button> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Layout({ children }) { | ||
return children | ||
} | ||
|
||
export function generateStaticParams() { | ||
return [{ slug: 'foo' }] | ||
} |