From b78d4db570f4822d00013cd76f85d9fcf6c43db8 Mon Sep 17 00:00:00 2001 From: Melloware Date: Tue, 9 Jan 2024 15:12:21 -0500 Subject: [PATCH] Fix useVisible (#5715) --- .../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..368e1314cd 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); } - } - - }, []); + }; + }); return isVisible; }; -export default useVisible; \ No newline at end of file +export default useVisible;