Skip to content

useId

This hook allows you to create an unique identificator and to change its value by calling the generate function.

{
identifier: string // By default ''
}

The hook returns a Symbol value for using it as a unique and unrepitable identifier:

import { useId } from '@tecnosamba21/sam-hooks'
export default function InputWithLabel() {
const id = useId('email')
return (
<div>
<label htmlFor={id}>Email</label>
<input id={id} type="email" />
</div>
)
}