This React hook propose an implementation of the precise linear interpolation formula
Wrapped in a useState
hook, you can keep in sync your input with your React component's lifecycles.
import { useLerp } from '@sugardarius/react-use-algos';
export function ComputeLerp() {
const { value, compute } = useLerp(10, 20, 6);
return (
<div>
<button
onClick={() => {
compute();
}}
>
Compute it!
</button>
<span>
{value}
</span>
</div>
);
}