Skip to main content
Version: 5.6.0



setTimeout hook for react.


npm install --save rooks

Importing the hook​

import { useTimeout } from 'rooks';


function TimeoutComponent() {
function doAlert() {
window.alert('timeout expired!');
const { start, clear } = useTimeout(doAlert, 2000);
return (
<button onClick={start}> Start timeout </button>
<button onClick={clear}> Clear timeout </button>

render(<TimeoutComponent />);


ArgumentsTypeDescriptionDefault value
callbackfunctionFunction to be executed in timeoutundefind
delayNumberNumber in milliseconds after which callback is to be run0

Returned Object keys​

Returned object attributesTypeDescription
clearfunctionClear the timeout
startfunctionStart the timeout
isActivebooleanIs the timeout active

Codesandbox Example​

Basic Usage​

Join Bhargav's discord server​

You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.