useIsDocumentVisible
Tracks document visibility using the document.visibilityState property
The useIsDocumentVisible
hook is helpful when you want to detect a visibility change in the document.
The property returns a boolean value, with true
meaning visible
and false
meaning ‘hidden’, as per the document.visibilityState
property.
useIsDocumentVisible
Tab Away count is : 0
Try changing the tab and check the count valueUsage
Import the hook from @abhushanaj/react-hooks
and use in required component;
Properties
- On the server snapshot for the component (when doing SSR), the
isVisible
property returnstrue
by default.
API Reference
Return Value
Parameter | Type | Description | Default |
---|---|---|---|
isVisible | boolean | Whether the document is visible or not. | N/A |