aboutsummaryrefslogtreecommitdiff
path: root/examples/react-fast-refresh-test/src/components/RenderCounter.tsx
blob: ed2f00b5682e8ececa62c01bcc3106456b5b8de2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import React from "react";

export function RenderCounter({ name, children }) {
  const counter = React.useRef(1);
  return (
    <div className="RenderCounter">
      <div className="RenderCounter-meta">
        <div className="RenderCounter-title">
          {name} rendered <strong>{counter.current++} times</strong>
        </div>
        <div className="RenderCounter-lastRender">
          LAST RENDER:{" "}
          {new Intl.DateTimeFormat([], {
            timeStyle: "long",
          }).format(new Date())}
        </div>
      </div>
      <div className="RenderCounter-children">{children}</div>
    </div>
  );
}