mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
32 lines
625 B
TypeScript
32 lines
625 B
TypeScript
'use client'
|
|
|
|
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 />
|
|
</>
|
|
)
|
|
}
|