React hook for api-poller-worker
use-api-poller-worker is a React hook that you can use to integrate
api-poller-worker into your React app.
Table of contents
npm install use-api-poller-worker
This hook takes the same options as the
ApiPollerWorker class from
api-poller-worker, plus an extra
callback argument which will be called when the underlying worker emits a message.
It's recommended to wrap your callback in
React.useCallback, so that your app does not unnecessarily re-render multiple times.
This is the default export.
Msg<T> come from
api-poller-worker. You might want to import
Msg<T> for type safety. This library re-exports
Msg<T> for convenience.
useApiPollerWorker also accepts a generic,
T for the type of resource you're polling.
Represents the contents of a message from the underlying polling library.