Dead-simple, zero-config React hook lib for detecting page visibility 👁️
npm install use-page-visibilityDead-simple, React hook lib for detecting page visibility 👁️
``bash`
npm install use-page-visibility
or with yarn
`bash`
yarn add use-page-visibility
`jsx
...
import usePageVisibility from 'use-page-visibility';
function App() {
const handleVisibilityChange = (visible) => {
if (visible) playVideo();
else pauseVideo();
}
usePageVisibility(handleVisibilityChange);
return ...
}
`
usePageVisibility(fn, delay)
Type: function
Callback function to run when page visibility changes. A boolean value (indicating whether the page is visible or not) will be passed as an argument to this function.
Type: number`
Number of milliseconds to wait before responding to page visibility change
- react-thanos - React hooks implementation of Google's "Thanos" easter egg
This project is licensed under MIT