UNPKG

acud

Version:

acg react 组件库

27 lines • 938 B
import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from 'react'; /** * This function will try to call requestIdleCallback if available to save performance. * No need `getLabel` here since already fetch on `rawLabeledValue`. */ export default (function (values) { var cacheRef = React.useRef({ valueLabels: new Map() }); return React.useMemo(function () { var valueLabels = cacheRef.current.valueLabels; var valueLabelsCache = new Map(); var filledValues = values.map(function (item) { var _a; var value = item.value; var mergedLabel = (_a = item.label) !== null && _a !== void 0 ? _a : valueLabels.get(value); // Save in cache valueLabelsCache.set(value, mergedLabel); return _extends(_extends({}, item), { label: mergedLabel }); }); cacheRef.current.valueLabels = valueLabelsCache; return [filledValues]; }, [values]); });