A lightweight React hook-based queue utility that processes items in FIFO order. Version 0.1.1 is the latest stable release, with no recent updates. Designed for simple queuing needs in React applications, it offers a single hook that manages a queue and triggers a user-provided process function for each item. Unlike more complex state management solutions, it focuses solely on queue functionality and is fully typed with TypeScript definitions. Ideal for scenarios like throttling API calls or sequential task processing.
npm install use-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates hook initialization with a process function, queue state, and add action.
Ensure done() is invoked after processing each item.
Wrap done() in a try-finally or guard against double invocation.
Use the add function or re-queue via the hook return value.
Consider alternatives like useReducer-based queues for modern React.
Check that queue is an array before using array methods: if (Array.isArray(queue)) { ... }Move useQueue call to the top level of the component, not inside conditionals.
Define process with a second parameter (done) and invoke it when done: const process = (item, done) => { ... done(); }