React hook for subscribing to document visibility
Switch branches/tags
Nothing to show
Clone or download
Latest commit 6170e2f Dec 6, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore 👀 init Oct 25, 2018
.travis.yml 👀 init Oct 25, 2018
LICENSE 👀 init Oct 25, 2018
README.md rename/api updates Oct 25, 2018
example.html 👀 init Oct 25, 2018
example.js rename/api updates Oct 25, 2018
index.d.ts rename/api updates Oct 25, 2018
index.js Default document visibility to true for SSR (#2) Dec 6, 2018
index.js.flow rename/api updates Oct 25, 2018
package.json 1.2.0 Dec 6, 2018
test-setup.js 👀 init Oct 25, 2018
test.js rename/api updates Oct 25, 2018
yarn.lock 👀 init Oct 25, 2018

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"

  // ...
}