useId
If a default is not provided, generate an id.
install | yarn add @react-aria/utils |
---|---|
version | 3.10.0 |
usage | import {useId} from '@react-aria/utils' |
API#
useId(
(defaultId: string
)): string
Introduction#
The useId
hook creates an autogenerated unique id
for an element. An id
from props can used instead of the autogenerated id
when available.
Example#
let elementId = useId();
let componentId = useId(propsid);
let elementId = useId();
let componentId = useId(propsid);
let elementId = useId();
let componentId = useId(
propsid
);