ArnasJack / use-window-focus

React Hook to check if window is focused

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

React Hook to check if window is focused

License:MIT License


Languages

Language:TypeScript 89.2%Language:JavaScript 7.5%Language:Shell 3.3%