@tremendous/help
    Preparing search index...

    Function usePolling

    • Hook to trigger a poll function at a given interval.

      Parameters

      • options: PollingOptions

        The polling options.

      Returns ReturnType

      • The polling return type.
      const { attempts, status, start, pause, restart } = usePolling({
      interval: 1000,
      maxAttempts: 5,
      poll: async () => {
      console.log('Polling...');
      },
      });

      return (
      <div>
      <p>Attempts: {attempts}</p>
      <p>Status: {status}</p>
      <button onClick={start}>Start</button>
      <button onClick={pause}>Pause</button>
      <button onClick={restart}>Restart</button>
      </div>
      );