Registry / productivity / react-use-queue

react-use-queue

JSON →
library0.5.0jsnpmunverified

A lightweight job-based asynchronous queue hook for React 16.8+ and React Native. v0.5.0 is the current stable release; no regular cadence. Key differentiator: minimal API—add tasks or promises, get a callback on completion. Lacks built-in WebWorker support and automated tests. No dependencies besides React peer dependency.

productivity
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Default export; named import will not work.

import useQueue from 'react-use-queue';

ESM-only; CommonJS require with destructuring will fail.

const Queue = useQueue();

Library ships TypeScript definitions; no extra type import needed.

import useQueue from 'react-use-queue';

Shows basic usage: import the hook, create a queue, add tasks (sync and async), and listen for completion.

import React from 'react'; import useQueue from 'react-use-queue'; function App() { const Queue = useQueue(); const handleClick = () => { Queue.addJob({ task: () => console.log('Task executed'), }); Queue.addJob({ task: () => new Promise(resolve => { setTimeout(() => { console.log('Async task done'); resolve(); }, 1000); }), }); Queue.onComplete(() => { console.log('All tasks complete'); }); }; return <button onClick={handleClick}>Start Queue</button>; } export default App;
Debug
Known footguns
breakingVersion 0.5.0 changed 'addJob' to accept both objects with 'task' key and bare callback functions.
gotchauseQueue is a default export, not named.
gotchaQueue methods are not properly typed in some versions; TypeScript may show 'any' type.
gotchaNo built-in concurrency control; all tasks run sequentially in order added.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
17 hits · last 30 days
gptbot
3
bytedance
2
mj12bot
1
ahrefsbot
1
Resources