The polling options.
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>
);
Hook to trigger a poll function at a given interval.