React hook for accessing viewport visibility
npm install react-hook-viewport-visibilityA React hook for detecting viewport visibility state.
Using npm:
``sh`
npm install --save react-hook-viewport-visibility
Using yarn:
`sh`
yarn add react-hook-viewport-visibility
`jsx
import React from 'react'
import useViewportVisibility from 'react-hook-viewport-visibility'
const ComponentWithViewportVisibility = () => {
const viewportVisibility = useViewportVisibility()
return (
Viewport visibility: {viewportVisibility}
Notes
The value returned by the hook can either be
'visible', 'hidden' and 'prerender'.However the value
'prerender'` is a non-standard feature and therefore browser support for this value is optional and might be poor.Contributions are welcome. File bug reports, create pull requests, feel free to reach out at tothab@gmail.com.
LGPL-3.0