From 99f556b77b3fa2712ee2537b29fe4cc28c0b9155 Mon Sep 17 00:00:00 2001 From: Melloware Date: Tue, 9 Jan 2024 14:56:19 -0500 Subject: [PATCH] Update useVisible.js --- .../templatefeaturesanimation/useVisible.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/templates/templatefeaturesanimation/useVisible.js b/components/templates/templatefeaturesanimation/useVisible.js index 7ff3ac7b8f..13584e17f9 100644 --- a/components/templates/templatefeaturesanimation/useVisible.js +++ b/components/templates/templatefeaturesanimation/useVisible.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import { useEffect, useState } from 'react'; const useVisible = (element, rootMargin = 0.2) => { const [isVisible, setIsVisible] = useState(false); @@ -8,7 +8,7 @@ const useVisible = (element, rootMargin = 0.2) => { ([entry]) => { setIsVisible(entry.isIntersecting); }, - { threshold: rootMargin }, + { threshold: rootMargin } ); if (element.current) { @@ -17,13 +17,13 @@ const useVisible = (element, rootMargin = 0.2) => { return () => { if (observer && element.current) { - observer.unobserve(element.current) + // eslint-disable-next-line react-hooks/exhaustive-deps + observer.unobserve(element.current); } - } - - }, []); + }; + }, [element, rootMargin]); return isVisible; }; -export default useVisible; \ No newline at end of file +export default useVisible;