next.js/test/e2e/react-compiler/pages/pages-router.tsx
pages-router.tsx30 lines611 B
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 />
    </>
  )
}
Quest for Codev2.0.0
/
SIGN IN