diff --git a/components/GradientBG.tsx b/components/GradientBG.tsx index 3c28d1f..14a93f6 100644 --- a/components/GradientBG.tsx +++ b/components/GradientBG.tsx @@ -3,12 +3,15 @@ import { Gradient } from '../Gradient.js' export const GradientBG = () =>{ - // Create your instance - const gradient = new Gradient(); - useEffect(() => { // Call `initGradient` with the selector to your canvas - gradient.initGradient('#gradient-background') + const canvasElement = document.getElementById("gradient-background"); + const gradient: any = new Gradient(); + if (canvasElement) { + gradient.initGradient("#gradient-background"); + } else { + gradient.pause(); + } }, []); return (