Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
use-animation-frame
Advanced tools
Readme
A hook to effortlessly run requestAnimationFrame()
in React (demo):
import useAnimationFrame from 'use-animation-frame';
const Counter = () => {
const [time, setTime] = useState(0);
useAnimationFrame(e => setTime(e.time));
return <div>Running for:<br/>{time.toFixed(1)}s</div>;
};
Inspired by CSS-Tricks' Using requestAnimationFrame with React Hooks and my twitter reply.
Accepts a function that will be called on each requestAnimationFrame step. If there's a re-render and a new function is created, it'll use that instead of the previous one:
useAnimationFrame(callback);
The callback receives a single parameter, which is an object with two properties (based on the performance.now()
API):
time
: the absolute time since the hook was first mounted. This is useful for wall clock, general time, etc.delta
: the time since the hook was run last. This is useful to measure e.g. FPS.All times are in the International System of Units seconds, including decimals.
With my other library use-interpolation it's easy to calculate the FPS (see in CodeSandbox):
import React, { useState } from "react";
import useInterpolation from 'use-interpolation';
import useAnimationFrame from 'use-animation-frame';
const Counter = () => {
const [time, setTime] = useState(0);
// 1s of interpolation time
const [fps, setFps] = useInterpolation(1000);
useAnimationFrame(e => {
setFps(1 / e.delta);
setTime(e.time);
});
return (
<div>
{time.toFixed(1)}s
<br />
{fps && Math.floor(fps.value)} FPS
</div>
);
};
FAQs
A React hook to run requestAnimationFrame seamlessly
The npm package use-animation-frame receives a total of 321 weekly downloads. As such, use-animation-frame popularity was classified as not popular.
We found that use-animation-frame 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.