Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client'

export default function ClientComp({ data }: { data: { title: string } }) {
return (
<pre>
<div>Hello World</div>
{data.title}
</pre>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Link from 'next/link'

export default function Page() {
return (
<p>
other page <Link href="/">home</Link>
</p>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ClientComp from './client'

export default async function Page() {
const topic = { title: 'Topic', fields: { featured: [] } }
const guide = { title: 'Guide', fields: { topic: [topic] } }
const featured = {
title: 'Featured',
fields: {
content: [guide],
topic, // points back to the same topic
},
}

// Circular reference: topic -> featured[] -> content[] -> topic
topic.fields.featured.push(featured)

return (
<div>
<ClientComp data={topic} />
Other
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { nextTestSetup } from 'e2e-utils'

describe('circular-reference-client-component', () => {
const { next } = nextTestSetup({
files: __dirname,
env: {
NEXT_DEBUG_BUILD: '1',
},
})

it('should not have errors when collecting segment data for a page with a circular reference to a client component', async () => {
expect(next.cliOutput).not.toContain(
'Error: Route / errored during segment collection'
)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig
Loading