Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/franciscop/use-interpolation

A hook to interpolate values easily in React
https://github.com/franciscop/use-interpolation

Last synced: 13 days ago
JSON representation

A hook to interpolate values easily in React

Awesome Lists containing this project

README

        

# use-interpolation

A hook to interpolate values easily in React with [Ola](https://github.com/franciscop/ola/):

```js
import useInterpolation from 'use-interpolation';

const Counter = () => {
// Either initialize it with a value or with no value
const [fps, setFps] = useInterpolation();
useAnimationFrame(e => {
setFps(1 / e.delta);
// Do something...
}, []);
if (!fps) return 'Loading...';
return

{fps.value}
;
};
```

It is useful for listening to remote values that change over time and setting like displaying a graph like [Ola](https://github.com/franciscop/ola/):

![Graph interpolation](https://raw.githubusercontent.com/franciscop/ola/master/docs/line.gif)

![Touch interpolation](https://raw.githubusercontent.com/franciscop/ola/master/docs/ball.gif)

![Many points interpolation](https://raw.githubusercontent.com/franciscop/ola/master/docs/dots.gif)