1.0.9 • Published 2 years ago

use-tab-visibility v1.0.9

Weekly downloads
43
License
MIT
Repository
github
Last release
2 years ago

Use Tab Visibility

A (simple) zero-dependency way to tell if your React app is being run in the currently active tab.

Blazing Fast Blazing Fast Blazing Fast

Simply import the hook and pull the visible key off of the returned object. This value will let you know if the tab is currently visible.

The React hook is using the Page Visibility API under the hood is and compatible down to IE 10.

A change in visibility will trigger a re-render.

View on NPM

Basic usage:

import React from 'react';
import useTabVisibility from 'use-tab-visibility';

function App() {
  const { visible } = useTabVisibility();
  console.warn(visible);

  return <div>This tab is current {visible ? 'visible' : 'not visible'}</div>;
}
1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago