react-hook-on-screen
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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('the div is visible?', isVisible)
}, [isVisible])

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

Dependencies (1)

Dev Dependencies (5)

Package Sidebar

Install

npm i react-hook-on-screen

Weekly Downloads

28

Version

1.0.1

License

ISC

Unpacked Size

2.64 kB

Total Files

4

Last publish

Collaborators

  • ifdouglas