usePageVisibility

Watch for to know when a document becomes visible or hidden.

Usage

import React from "react";
import usePageVisibility from 'funda-ui/Utils/usePageVisibility';
 
const App = () => {
 
    usePageVisibility(
        () => console.log("🍏 Page is now visible — current tab is active."),
        () => console.log("🍎 Page is hidden — switched to another tab or minimized."),
        () => console.log("🎬 Page initialized while visible.")
    );
 
    return <div>Try switching tabs to see the console output.</div>;
};