
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-use-queue
Advanced tools
react and react-nativeA very small and basic implementation of an asyncronous queue. It's an easy way to add jobs to a list and add a callback to be fired when all of the jobs are complete.
While it's not exactly crammed full of features, it's a convenient and lightweight way to do work on unused cycles.
First, add it to your project as you normally would.
$ npm i -s react-use-queue
import useQueue from "react-use-queue";
Next, simply use the hook as so.
const Queue = useQueue();
Now, you can add tasks:
Queue.addJob({
task: () => doSomething()),
});
As of 0.5.0 you can also just add callbacks like so
Queue.addJob(doSomething),
You can even add promises and do something with their result:
Queue.addJob({
task: () => doSomething().then(result => doSomethingElse(result)),
});
You should think about wrapping the addJob() function in a promise:
const doSomethingAndReturn = () => {
return new Promise<string>((resolve, reject) => {
Queue.addJob({
task: () => doSomething().then(result => resolve(result)),
});
});
};
Which you can then use elsewhere like so...
const result = await doSomethingAndReturn()
If you're on react for the web, you can use this queue in your ServiceWorker to do tasks on a background thread. If you're using react-native like me, this will execute on the main JS thread, unless the job you're passing spawns it's own thread, like react-native-ffmpeg does for example.
FAQs
A simple task queue implementation for React
We found that react-use-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.