use-spring
v4.7.0arrow_drop_downv4.7.0
STATUS
Passing
DOWNLOADS
48
VISIBILITY
Public
PUBLISHED
6 years ago
SIZE
N/A
1 contributor
Like
Install use-spring as a package?
Copied
npm i @bit/giladshoham.react-hooks.use.use-spring
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
and packages in Bit or NPM to the example. any of the 1 million componentstoggle layout
chevron_left
chevron_right
useSpring
React animation hook that updates a single numeric value over time according to spring dynamics.
Usage
import {useSpring} from 'react-use';
const Demo = () => {
const [target, setTarget] = useState(50);
const value = useSpring(target);
return (
<div>
{value}
<br />
<button onClick={() => setTarget(0)}>Set 0</button>
<button onClick={() => setTarget(100)}>Set 100</button>
</div>
);
};
Reference
const currentValue = useSpring(targetValue);
const currentValue = useSpring(targetValue, tension, friction);