How to add delay in React.js?

Pure typescript Solution

You would be able to create delay function with async:

function timeout(delay: number) {
    return new Promise( res => setTimeout(res, delay) );
}

And then call the function:

await timeout(1000); //for 1 sec delay

Leave a Comment