Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Smart spinner helper for React, to manage the duration of loading states.
Smart Spinner Helper for React
There are a few annoyances when working with spinners. Network request can be so fast that rendering a spinner does more harm than good. Why render a spinner when loading the data only takes like 50ms?
This can be fixed by adding a delay. Only show the spinner when the request takes longer than 200ms for example. And what happens when the request takes 210ms? Right, we see a spinner for 10ms. This flicker can be annoying.
spin-delay
solves these issues by wrapping your booleans, and only returning
true after the delay
, and for a minimum time of minDuration
. This way
you're sure that you don't show unnecessary or very short living spinners.
Sandbox -> https://codesandbox.io/s/spin-delay-jlp2c
With npm:
npm install --save spin-delay
With yarn:
yarn add spin-delay
The examples below use the following data object:
import { useSpinDelay } from 'spin-delay';
function MyComponent() {
const [{ loading }] = useFetch('http://example.com');
// options are optional, and default to these values
const showSpinner = useSpinDelay(loading, { delay: 500, minDuration: 200 });
if (showSpinner) {
return <Spinner />;
}
// ...
}
Thanks goes to these wonderful people (emoji key):
Stephan Meijer 🤔 💻 🚇 🚧 ⚠️ | Peter Hozák 🤔 ⚠️ | Eric Hosick 📖 | Supachai Dev 💻 | Kent C. Dodds 💻 | Phong Chu 💻 | Joe Porpeglia 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Smart spinner helper for React, to manage the duration of loading states.
The npm package spin-delay receives a total of 42,559 weekly downloads. As such, spin-delay popularity was classified as popular.
We found that spin-delay demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.