Implement a useTimeout hook that invokes a callback function after a specified delay.
Note that the hook can be called again with different values after the initial call:
The primary benefit of useTimeout is that you do not have to manually call clearTimeout() if the component unmounts before the timer expires.
export default function Component() {const [loading, setLoading] = useState(true);useTimeout(() => setLoading(false), 1000);return (<div><p>{loading ? 'Loading' : 'Ready'}</p></div>);}
callback: () => void: A function to be called after the specified delaydelay: number | null: The delay in milliseconds before invoking the callback function. If null, the timeout is clearedNothing.
callback if the callback changes before the timeout fires.null for delay should clear the timeout and avoid scheduling a new one.delay changes.console.log() statements will appear here.