Skip to content

A simple and performatic react hook that returns a true boolean value when a component become visible on the screen

Notifications You must be signed in to change notification settings

ifdouglas/react-hook-on-screen

Repository files navigation

react-hook-on-screen

A simple and performatic react hook that returns a true boolean value when a component become visible on the screen

Example

import { createRef, useEffect } from 'react'
import useOnScreen from 'react-hook-on-screen'

const ref = createRef<HTMLDivElement>()
const isVisible = useOnScreen(ref)

useEffect(() => {
  console.log('Is this visible?', isVisible)
}, [isVisible])

<div ref={ref}>
  react-hook-on-screen
</div>

About

A simple and performatic react hook that returns a true boolean value when a component become visible on the screen

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published