Skip to content

Instantly share code, notes, and snippets.

@longseespace
Created January 13, 2022 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longseespace/f5ab22f9264d3d40b05e722c12eb5b67 to your computer and use it in GitHub Desktop.
Save longseespace/f5ab22f9264d3d40b05e722c12eb5b67 to your computer and use it in GitHub Desktop.
Debug Component Mount Lifecycle
import { useMountDebug } from './useMountDebug';
function SignInForm(props) {
useMountDebug('SignInForm');
return (<div></div>)
}
import { useEffect } from 'react';
export function useMountDebug(label = 'Component') {
useEffect(() => {
console.log(label, 'mounted');
return () => {
console.log(label, 'unmounted');
};
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment