rsuite
Version:
A suite of react components
16 lines (13 loc) • 365 B
JavaScript
import { useDebugValue, useRef } from 'react';
import uniqueId from 'lodash/uniqueId';
/**
* Used for generating unique ID for DOM elements
*/
export default function useInternalId(namespace) {
var idRef = useRef();
if (!idRef.current) {
idRef.current = uniqueId("internal://" + namespace);
}
useDebugValue(idRef.current);
return idRef.current;
}