Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Latest commit

 

History

History
28 lines (24 loc) · 766 Bytes

use-lerp.hook.md

File metadata and controls

28 lines (24 loc) · 766 Bytes

useLerp

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.

How to use it?

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>
    );
}