Files
starface-outlook-sync-addin/node_modules/@fluentui/react-hooks/lib-commonjs/useId.js
T
Stefan Hacker 37ad745546 first commit
2026-04-03 09:38:48 +02:00

23 lines
933 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useId = useId;
var React = require("react");
var utilities_1 = require("@fluentui/utilities");
/**
* Hook to generate a unique ID in the global scope (spanning across duplicate copies of the same library).
*
* @param prefix - Optional prefix for the ID
* @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
* without conditioning the hook call
* @returns The ID
*/
function useId(prefix, providedId) {
// getId should only be called once since it updates the global constant for the next ID value.
// (While an extra update isn't likely to cause problems in practice, it's better to avoid it.)
var ref = React.useRef(providedId);
if (!ref.current) {
ref.current = (0, utilities_1.getId)(prefix);
}
return ref.current;
}
//# sourceMappingURL=useId.js.map