import { useEffect, useState, useRef } from 'react'; import { runtime } from '../../../build/module'; const secondsUntilIdle = 5; export function IdleLocks() { const containerRef = useRef(null); const [isIdle, setIsIdle] = useState(true); useEffect(() => { if (!containerRef.current) return; // Add the idle listener to the container. By default addIdleListener will attach // the listener to the global document and use a 30s idle timeout. An optional callback // can be provided to be notified when the idle state changes. // // Options: // - Defaults: runtime.addIdleListener(); // - With idle timeout: runtime.addIdleListener(5); // - With callback: runtime.addIdleListener(5, (idle) => { ... }); // - With custom container: runtime.addIdleListener(containerEl, 5, (idle) => { ... }); return runtime.addIdleListener( containerRef.current, secondsUntilIdle, setIsIdle ); }, []); return (
Interact with this container to lock.
Status:  {isIdle ? ( Idle ) : ( Active )}
); }