-
-
)
}
+
+function Counter() {
+ const [clickCount, setClickCount] = React.useState(0)
+ const renderCount = React.useRef(0)
+ renderCount.current += 1
+
+ console.log('Counter render', renderCount.current)
+
+ if (
+ typeof performance !== 'undefined' &&
+ typeof performance.measure !== 'undefined'
+ ) {
+ performance.measure(
+ `Counter render ${renderCount.current}`,
+ {
+ start: performance.now(),
+ duration: 50,
+ },
+ )
+ }
+
+ React.useEffect(() => {
+ return function cleanup() {
+ // we are about to unmount!
+ console.log('Counter unmount', renderCount.current)
+
+ if (
+ typeof performance !== 'undefined' &&
+ typeof performance.measure !== 'undefined'
+ ) {
+ performance.measure(
+ `Counter unmount ${renderCount.current}`,
+ {
+ start: performance.now(),
+ duration: 50,
+ },
+ )
+ }
+ }
+ }, [])
+
+ return (
+
+
Render count:{renderCount.current}
+
+
+
+ )
+}