UNPKG

uniforms

Version:
15 lines (14 loc) 509 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.randomIds = randomIds; // Workaround for SSR // https://github.com/vazco/uniforms/issues/40 // https://github.com/facebook/react/issues/4000 function randomIdsGenerator(prefix) { let counter = 0; return () => `${prefix}-${('000' + (counter++).toString(36)).slice(-4)}`; } const randomIdPrefix = randomIdsGenerator('uniforms'); function randomIds(prefix = randomIdPrefix()) { return randomIdsGenerator(prefix); }