Files
vercel__next.js/test/e2e/react-compiler/pages/pages-router.tsx
Jiwon Choi 7e741b4207 Handle target option in React Compiler for Pages + React 18 (#91500)
### Why?

`test/e2e/app-dir/catch-error/catch-error-react-compiler.test.ts` is
skipped in CI due to incompatibility with React 18 tests.

```
Module not found: Can't resolve 'react/compiler-runtime'
> 1 | import { c as _c } from "react/compiler-runtime";
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Failed CI:
https://github.com/vercel/next.js/actions/runs/23170738194/job/67327462789#step:36:317
x-ref:
https://react.dev/reference/react-compiler/target#targeting-react-17-or-18

---------

Co-authored-by: Sebastian "Sebbie" Silbermann <12292047+eps1lon@users.noreply.github.com>
Co-authored-by: Benjamin Woodruff <180404+bgw@users.noreply.github.com>
Co-authored-by: Sebastian Silbermann <eps1lon@users.noreply.github.com>
2026-04-09 15:21:29 +00:00

30 lines
611 B
TypeScript

import { Profiler, useReducer } from 'react'
if (typeof window !== 'undefined') {
;(window as any).staticChildRenders = 0
}
function StaticChild() {
return (
<Profiler
onRender={(id, phase) => {
;(window as any).staticChildRenders += 1
}}
id="test"
>
<div>static child</div>
</Profiler>
)
}
export default function Page() {
const [count, increment] = useReducer((n) => n + 1, 1)
return (
<>
<div data-testid="parent-commits">Parent commits: {count}</div>
<button onClick={increment}>Increment</button>
<StaticChild />
</>
)
}