https://github.com/jpalumickas/use-window-focus
React Hook to check if window is focused
https://github.com/jpalumickas/use-window-focus
hacktoberfest hooks javascript react react-hooks
Last synced: about 1 year ago
JSON representation
React Hook to check if window is focused
- Host: GitHub
- URL: https://github.com/jpalumickas/use-window-focus
- Owner: jpalumickas
- License: mit
- Created: 2020-02-28T11:26:26.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-02-05T22:14:05.000Z (over 1 year ago)
- Last Synced: 2025-03-30T01:13:04.379Z (over 1 year ago)
- Topics: hacktoberfest, hooks, javascript, react, react-hooks
- Language: TypeScript
- Homepage:
- Size: 3.83 MB
- Stars: 38
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# use-window-focus
React Hook to show if window is focused or not
## Installation
```sh
yarn add use-window-focus
```
## Usage
```jsx
import React from 'react';
import useWindowFocus from 'use-window-focus';
export default () => {
const windowFocused = useWindowFocus();
return (
{windowFocused ? 'Focused' : 'Not focused'}
);
}
```
## License
The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).