useRefresh()function

useRefresh(interval: number): void
ParamType
intervalnumber
The refresh period in milliseconds. required

Re-render a component automatically on a fixed interval.

  • Holds the current time in state and updates it every interval milliseconds, forcing a refresh.
  • Clears the timer on unmount or when interval changes.

Examples

useRefresh(1000); // re-renders once per second, e.g. for a live clock