use-animated-number
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Vite Plugin - React.js Animated Number

A custom React hook for animating numbers in React.js applications.

version

Installation

You can install this plugin through npm:

npm i use-animated-number

Usage


Example

import { useState } from "react";
import useAnimatedNumber from "use-animated-number";

export default function Header() {
    const [ balance, setBalance ] = useState<number>(0);
    const animatedBalance: string = useAnimatedNumber(balance);

    const increase = () => {
        const randomIncrement: number = Math.floor(Math.random() * 100) + 1;
        setBalance(prevState => prevState + randomIncrement);
    }

    return (
        <section>
            <span> {animatedBalance} </span>
            <button onClick={increase}>Increase balance</button>
        </section>
    )
}

License

License

Package Sidebar

Install

npm i use-animated-number

Weekly Downloads

1

Version

0.0.4

License

GPL-3.0

Unpacked Size

38.6 kB

Total Files

6

Last publish

Collaborators

  • mustafadalga