Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Dynamic Usage Error when using previewData with generateStaticPa…
…rams and appDir (#43395) fixes #43392 <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change that you're making: --> ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [] Related issues linked using `fixes #number` - [] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: JJ Kasper <jj@jjsweb.site>
- Loading branch information
1 parent
30c9627
commit 1c89da6
Showing
3 changed files
with
67 additions
and
4 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
29 changes: 29 additions & 0 deletions
29
test/e2e/app-dir/app-static/app/ssg-preview/[[...route]]/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,29 @@ | ||
import { previewData } from 'next/headers' | ||
|
||
export default function Page() { | ||
const previewDataResult = previewData() | ||
|
||
return ( | ||
<main> | ||
<pre id="preview-data"> | ||
{JSON.stringify({ previewData: previewDataResult })} | ||
</pre> | ||
</main> | ||
) | ||
} | ||
|
||
export const generateStaticParams = async () => { | ||
const paths = [ | ||
{ | ||
route: [], | ||
}, | ||
{ | ||
route: ['test'], | ||
}, | ||
{ | ||
route: ['test-2'], | ||
}, | ||
] | ||
|
||
return paths | ||
} |