idhook

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

Usage no npm install needed!

<script type="module">
  import idhook from 'https://cdn.skypack.dev/idhook';
</script>

README

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.