useInViewport

Detect whether an element is visible in the viewport.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

The label follows the visibility of the box.

APIs

useInViewport

const useInViewport = <T extends HTMLElement = HTMLElement>() => {
  ref: (element: T | null) => void
  inViewport: boolean
}
Edit this page on GitHub