use-id
A React hook to generate a very-likely unique id, persistent across re-renders.
Install
npm i @bscop/use-id
Usage
Default behavior:
import useId from "@bscop/use-id";
useId(); // aS42hp
Custom behavior:
import useId from "@bscop/use-id";
useId({ length: 10, prefix: "app" }); // app-aS42hpZn9Q
-
length
: determine the length of the random part of the id (default is 6). -
prefix
: define a prefix that will be prepended to the random id (default, no prefix).
Contribute
Read the guidelines.
Run tests
npm test
Coverage
Coverage reports are hosted on codecov.
npm run badge:coverage -- --token=<guid>
Bruno Scopelliti
www.brunoscopelliti.com