use-window-focus
TypeScript icon, indicating that this package has built-in type declarations

1.4.3 • Public • Published

use-window-focus

React Hook to show if window is focused or not

Installation

yarn add use-window-focus

Usage

import React from 'react';
import useWindowFocus from 'use-window-focus';

export default () => {
  const windowFocused = useWindowFocus();

  return (
    <div>
      <span>{windowFocused ? 'Focused' : 'Not focused'}</span>
    </div>
  );
}

License

The package is available as open source under the terms of the MIT License.

Dependencies (0)

    Dev Dependencies (17)

    Package Sidebar

    Install

    npm i use-window-focus

    Weekly Downloads

    6,388

    Version

    1.4.3

    License

    MIT

    Unpacked Size

    12.4 kB

    Total Files

    15

    Last publish

    Collaborators

    • jpalumickas