Open this example in the interactive library
Live preview
Source code
// components/DelayedHint.tsx
import { useState, useEffect } from "react";
export default function DelayedHint({ seconds = 10 }: { seconds?: number } = {}) {
const [ready, set] = useState(false);
useEffect(() => {
set(false);
const timer = setTimeout(() => set(true), Math.max(0, seconds) * 1000);
return () => clearTimeout(timer);
}, [seconds]);
return ready ? <p>Need help? Open the guide.</p> : null;
}
