chore: Enable recommended React eslint rules (#5600)

This commit is contained in:
Tom Moor
2023-07-24 21:23:54 -04:00
committed by GitHub
parent 8865d394c6
commit e0289aed40
60 changed files with 586 additions and 494 deletions

View File

@@ -1,12 +1,13 @@
import * as React from "react";
const isSupported = "IntersectionObserver" in window;
/**
* Hook to return if a given ref is visible on screen.
*
* @returns boolean if the node is visible
*/
export default function useOnScreen(ref: React.RefObject<HTMLElement>) {
const isSupported = "IntersectionObserver" in window;
const [isIntersecting, setIntersecting] = React.useState(!isSupported);
React.useEffect(() => {
@@ -28,7 +29,7 @@ export default function useOnScreen(ref: React.RefObject<HTMLElement>) {
observer?.unobserve(element);
}
};
}, []);
}, [ref]);
return isIntersecting;
}