You can use setTimeout()
function to delay a piece of code to execute by a specified number of milliseconds. To wait 30 seconds, you can use like this:
index.tsx113 chars4 lines
If you want to execute a piece of code repeatedly after a certain number of seconds, you can use setInterval()
function.
index.tsx114 chars4 lines
Note: setTimeout()
and setInterval()
are asynchronous functions, so the actual delay time may not be precisely 30 seconds, especially if your code is heavy or the browser is busy with other tasks.
gistlibby LogSnag