Skip to content

Commit

Permalink
test: fix async api tests (#71652)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Oct 22, 2024
1 parent 95720f4 commit 8275078
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Link from 'next/link'

export default function Layout({ children, modal, params }) {
export default async function Layout(props) {
const params = await props.params

const { children, modal } = props

return (
<>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import ClientComp from './client-component'
import { headers } from 'next/headers'

export default function Page() {
export default async function Page() {
// Opt-in to SSR.
headers()
await headers()
return <ClientComp />
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ClientComp from './client-component'
import { headers } from 'next/headers'

export default function Page() {
export default async function Page() {
// Opt-in to SSR.
headers()
await headers()
return <ClientComp />
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default async function Page({ params }) {
const { artist, album } = await params
return (
<div>
<h2>Album: {params.album}</h2>
<h2>Album: {album}</h2>
<ul>
{tracks.map((track) => (
<li key={track}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'

export default function Page({ params }) {
export default async function Page(props) {
const params = await props.params
const nextUrl = [...params.slug, 'slug']
return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'

export default function Page({ params }) {
export default async function Page(props) {
const params = await props.params
return (
<>
<Link href="/basic-route/inner">To basic inner</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'

export default function Page({ params }) {
export default async function Page(props) {
const params = await props.params
return (
<>
<Link href="/dynamic/first/second">To inner dynamic</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Link from 'next/link'

export const dynamicParams = false

export default function Page({ params }) {
export default async function Page(props) {
const params = await props.params
return (
<>
<Link
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const dynamicParams = false

export default function Page({ params }) {
export default async function Page() {
return <p>Static page</p>
}
3 changes: 2 additions & 1 deletion test/e2e/app-dir/searchparams-reuse-loading/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'

export default function Page({ searchParams }) {
export default async function Page(props) {
const searchParams = await props.searchParams
return (
<>
<div id="root-params">{JSON.stringify(searchParams)}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'

export default async function Home({ searchParams }) {
export default async function Home(props) {
const searchParams = await props.searchParams
return (
<div>
<h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'

export default async function Home({ searchParams }) {
export default async function Home(props) {
const searchParams = await props.searchParams
return (
<div>
<h1>
Expand Down
3 changes: 2 additions & 1 deletion test/integration/app-dir-export/app/another/[slug]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export function generateStaticParams() {
return [{ slug: 'first' }, { slug: 'second' }]
}

export default function Page({ params }) {
export default async function Page(props) {
const params = await props.params
return (
<main>
<h1>{params.slug}</h1>
Expand Down

0 comments on commit 8275078

Please sign in to comment.