- Deleted obsolete configuration files and unused components across various packages. - Updated package.json files to reflect the removal of dependencies. - Cleaned up code by removing unnecessary exports and unused imports in multiple modules. Signed-off-by: Innei <tukon479@gmail.com>
18 lines
472 B
TypeScript
18 lines
472 B
TypeScript
import { useLayoutEffect, useState } from "react"
|
|
|
|
export function usePageVisibility() {
|
|
const [isPageVisible, setIsPageVisible] = useState(!document.hidden)
|
|
|
|
useLayoutEffect(() => {
|
|
const handleVisibility = () => {
|
|
setIsPageVisible(!document.hidden)
|
|
}
|
|
document.addEventListener("visibilitychange", handleVisibility)
|
|
return () => {
|
|
document.removeEventListener("visibilitychange", handleVisibility)
|
|
}
|
|
}, [])
|
|
|
|
return isPageVisible
|
|
}
|