UNPKG

use-page-view

Version:

A React hook for tracking page views and user engagement time. This hook provides real-time tracking of how long users spend on a page, their activity status, and the ability to persist time tracking across page reloads.

1 lines 285 B
import e from"react";function t(t,n){let r=e.useRef(null),i=e.useRef(t);return e.useEffect(()=>{i.current=t},[t]),e.useEffect(()=>{let e=()=>i.current();if(typeof n==`number`)return r.current=window.setInterval(e,n),()=>window.clearInterval(r.current)},[n]),r}export{t as useInterval};