@talopl/use-random

1.0.1 • Public • Published

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




Package Sidebar

Install

npm i @talopl/use-random

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

1.86 kB

Total Files

3

Last publish

Collaborators

  • talopl