Skip to content

Commit

Permalink
example: add ref checking condition (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Sep 28, 2021
1 parent 6746f49 commit b6855b7
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 b6855b7

Please sign in to comment.