From ff8536f8c651461c9ccb343bf02c4a32b6ce931b Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Wed, 8 Feb 2023 17:58:06 +0100 Subject: [PATCH] fix --- components/GradientBG.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 (