useWindowFocus

Tags:

A React Hook that helps to detect whether the window is focused or not.

Demo

Source
Is window focused:
false

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const isFocused = useWindowFocus()

Returns

A boolean value that indicates whether the window is focused or not.