React Hook to show if window is focused or not
pnpm add use-window-focusimport useWindowFocus from 'use-window-focus';
export const App = () => {
const isWindowFocused = useWindowFocus();
return (
<div>
<span>{isWindowFocused ? 'Focused' : 'Not focused'}</span>
</div>
);
}The package is available as open source under the terms of the MIT License.