React hook for subscribing to document visibility
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 2 commits behind rehooks:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
example.html
example.js
index.d.ts
index.js
index.js.flow
package.json
test-setup.js
test.js
yarn.lock

README.md

@rehooks/document-visibility

React hook for subscribing to document visibility

Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.

You'll need to install react, react-dom, etc at ^16.7.0-alpha.0

Install

yarn add @rehooks/document-visibility

Usage

import useDocumentVisibility from '@rehooks/document-visibility';

function MyComponent() {
  let documentVisibility = useDocumentVisibility();
  // documentVisibility = "hidden" | "visible" | "prerender"

  // ...
}