Skip to content

Commit

Permalink
example: add ref checking condition
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Sep 28, 2021
1 parent 6746f49 commit 8f779ab
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/infinite-scroll/hooks/useOnScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export default function useOnScreen(ref) {
const [isIntersecting, setIntersecting] = useState(false)

useEffect(() => {
if (!ref.current) return

const observer = new IntersectionObserver(([entry]) =>
setIntersecting(entry.isIntersecting)
)
Expand Down

0 comments on commit 8f779ab

Please sign in to comment.