Skip to content

Commit

Permalink
[test] Avoid hydration errors in react-compiler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jan 15, 2025
1 parent e354e3a commit 185cf28
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/e2e/react-compiler/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use client'

import { useEffect } from 'react'

export default function Page() {
let heading: any = ''
let $_: any
if (typeof window !== 'undefined') {
// eslint-disable-next-line no-eval
const $_ = eval('$')
$_ = eval('$')
}

useEffect(() => {
if (Array.isArray($_)) {
heading = (
<h1 id="react-compiler-enabled-message">
{/* @ts-ignore */}
React compiler is enabled with <strong>{$_.length}</strong> memo slots
</h1>
)
document.getElementById('react-compiler-enabled-message')!.textContent =
`React compiler is enabled with ${$_!.length} memo slots`
}
}
})

return (
<>
<div>
{heading}
<h1 id="react-compiler-enabled-message" />
<p>hello world</p>
</div>
</>
Expand Down

0 comments on commit 185cf28

Please sign in to comment.