Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hydration error testcase when using useId() in a client component #53223

Merged
merged 1 commit into from
Jul 26, 2023
Merged
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
37 changes: 37 additions & 0 deletions test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,41 @@ describe('Error overlay for hydration errors', () => {

await cleanup()
})

it('should not show a hydration error when using `useId` in a client component', async () => {
const { cleanup, browser } = await sandbox(
next,
new Map([
[
'app/page.js',
outdent`
'use client'

import { useId } from "react"

export default function Page() {
let id = useId();
return (
<div className="parent" data-id={id}>
Hello World
</div>
);
}
`,
],
])
)

const logs = await browser.log()
const errors = logs
.filter((x) => x.source === 'error')
.map((x) => x.message)
.join('\n')

expect(errors).not.toInclude(
'Warning: Prop `%s` did not match. Server: %s Client: %s'
)

await cleanup()
})
})