1.0.1 • Published 4 years ago

@talopl/use-random v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

what is this?

This package is an custom hook for react for generating custom random numbers

Installation

npm i @talopl/use-random

how to use

The use-random hook accepts three arguments - the minimun number the random number can be, the maximum number it can be, and a boolean which determines whether it is an integer or not.

The use-random hook returns an array of two values - the number, and a function to update the number

demo

import useRandom from '@talopl/use-random';


function App() {
    const [number, updateNumber] = useRandom(5, 10, true) // will return an integer number between 5 and 10

    return (
        <div>{number}</div>
        <button onClick={updateNumber}>update the number</button>
    )
}