Skip to content

Repository files navigation

use-window-focus

React Hook to show if window is focused or not

Installation

pnpm add use-window-focus

Usage

import useWindowFocus from 'use-window-focus';

export const App = () => {
  const isWindowFocused = useWindowFocus();

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

License

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

About

React Hook to check if window is focused

Topics

Resources

Stars

40 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages