Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Created December 5, 2025 00:49
Show Gist options
  • Select an option

  • Save remarkablemark/226ec9d6993960f2e8adfdb36df5eee8 to your computer and use it in GitHub Desktop.

Select an option

Save remarkablemark/226ec9d6993960f2e8adfdb36df5eee8 to your computer and use it in GitHub Desktop.
React hook useFadeIn
import { useEffect, useState } from "react";
/**
* Trigger animation after component mounts with a slight delay for dramatic effect
*
* @param delay - The delay in milliseconds
* @returns A boolean indicating whether the element is visible
*/
function useFadeIn(delay) {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
const timer = setTimeout(() => setIsVisible(true), delay);
return () => clearTimeout(timer);
}, [delay]);
return isVisible;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment