Skip to content

Commit

Permalink
Update useVisible.js
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jan 9, 2024
1 parent 98c5b0d commit 99f556b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions components/templates/templatefeaturesanimation/useVisible.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -8,7 +8,7 @@ const useVisible = (element, rootMargin = 0.2) => {
([entry]) => {
setIsVisible(entry.isIntersecting);
},
{ threshold: rootMargin },
{ threshold: rootMargin }
);

if (element.current) {
Expand All @@ -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;
export default useVisible;

0 comments on commit 99f556b

Please sign in to comment.