/idhook

[deprecated] Generate unique ids to use in your HTML with an intuitive API.

Primary LanguageTypeScript

React 18 released useId, which replaces idhook. You don't need this anymore.


idhook

Generate unique ids to use in your HTML with a very intuitive API.

NPM JavaScript Style Guide

Install

npm install --save idhook

Usage

import React from "react";

import { useUniqueId } from "idhook";

const App = () => {
  const id = useUniqueId();
  return (
    <form>
      <label htmlFor={id("name")}>Name</label>
      <input id={id("name")} name="name" />

      <label htmlFor={id("email")}>Name</label>
      <input id={id("email")} name="email" />
    </form>
  );
};

Typescript

Works out of the box.

License

MIT © anilanar


This hook is created using create-react-hook.