1.0.0 • Published 1 year ago

react-unique-ids v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

��# React Unique IDS

React Unique IDS is a handy tool for React developers. It helps create special IDs for elements in your React apps. You can customize these IDs to suit your needs easily. It's great for managing IDs within React components, making your development process smoother

Installation & Usage

  • To install and set up the library, run:

    npm install react-unique-id
  • import the library

    import reactUniqueId from "react-unique-id";
  • Use it
    reactUniqueId();

Customization

  • To generate a unique ID, simply call the function:

    reactUniqueId();

    Output: A unique ID is generated with a length of 20 characters, containing uppercase letters, lowercase letters, numbers, and symbols.

    "bmYZWC*9DuLNxB@zcd5m";
  • To specify the length of the ID, pass the desired length as an argument:

    reactUniqueId(15);

    Output: A unique ID is generated with a length of 15 characters, containing uppercase letters, lowercase letters, numbers, and symbols.

    "NF7&4q#9F@pJH4o";
  • You can customize the character requirements by passing an object:

    const data = {
      length: 10,
      uppercase: true, // true if you need uppercase letters in the unique ID
      lowercase: false, // true if you need lowercase letters in the unique ID
      symbol: false, // true if you need symbol letters in the unique ID
      number: true, // true if you need number letters in the unique ID
    };
    
    reactUniqueId(data);

    OR

    const data = {
      length: 10,
      lowercase: false, // true if you need lowercase letters in the unique ID
      symbol: false, // true if you need symbol letters in the unique ID
    };
    
    reactUniqueId(data);

    Output: A unique ID is generated based on your customization/requirement.

    "BFU03WETS56B59U";

    !NOTE
    By default, all types are true.

    • To generate an ID of the format 23573527-aT2s%JR6@-YWDBSCYE, you can use the following configuration:

      const data = {
        length: [8, "number", 9, 8, "uppercase"],
        separater: "-",
      };
      
      reactUniqueId(data);

      Output: A unique ID is generated where the first 8 characters are numbers, the next 9 characters can be any type, and the last 8 characters are in uppercase. They are separated using a separator.

      "72324118-71*xW4fHC-ANTITOWI";
1.0.0

1 year ago