UNPKG

@nutui/nutui-react

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

28 lines (27 loc) 674 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "default", { enumerable: true, get: function() { return useUuid; } }); var _react = require("react"); var idCounter = {}; function uniqueId() { var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '$nut$'; if (!idCounter[prefix]) { idCounter[prefix] = 0; } var id = ++idCounter[prefix]; if (prefix === '$nut$') { return "".concat(id); } return "".concat(prefix).concat(id); } function useUuid() { var idRef = (0, _react.useRef)(uniqueId()); return idRef.current; }