0.2.0 • Published 4 years ago

use-interpolation v0.2.0

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

use-interpolation

A hook to interpolate values easily in React with Ola:

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 <div>{fps.value}</div>;
};

It is useful for listening to remote values that change over time and setting like displaying a graph like Ola:

Graph interpolation

Touch interpolation

Many points interpolation