@bscop/use-id
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

use-id

GitHub license npm version CircleCI Status Coverage

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

Dependencies (0)

    Dev Dependencies (20)

    Package Sidebar

    Install

    npm i @bscop/use-id

    Weekly Downloads

    93

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    14.3 kB

    Total Files

    9

    Last publish

    Collaborators

    • brunoscopelliti