Skip to content

Instantly share code, notes, and snippets.

@AlexGeb
Created July 21, 2025 07:35
Show Gist options
  • Select an option

  • Save AlexGeb/c54b092e17b57421a8f2db3d7a23d87a to your computer and use it in GitHub Desktop.

Select an option

Save AlexGeb/c54b092e17b57421a8f2db3d7a23d87a to your computer and use it in GitHub Desktop.
Hook that logs the render count of the component where it is used
import { useEffect, useRef } from "react";
export const useRenderCount = (label: string) => {
const count = useRef(0);
useEffect(() => {
count.current += 1;
// eslint-disable-next-line no-console
console.log(`${label} render count:`, count.current);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment