Published on

useRenderInfo Hook React

useRenderInfo Hook React

useRenderInfo Hook React

useRenderInfo Code and Usage

useRenderInfo is a hook to get information about the render of a component.

import { useEffect } from "react";

const useRenderInfo = () => {
  useEffect(() => {
    console.log("Component has rendered.");

    return () => {
      console.log("Component will unmount.");
    };
  }, []);
};

// Usage
const RenderInfoExample = () => {
  useRenderInfo();

  return (
    <div>
      <p>This component logs render information to the console.</p>
    </div>
  );
};