Latest updates from IceHrmPro

This commit is contained in:
Thilina Pituwala
2020-05-20 18:47:29 +02:00
parent 60c92d7935
commit 7453a58aad
18012 changed files with 2089245 additions and 10173 deletions

View File

@@ -0,0 +1,18 @@
import React from 'react';
/**
* Return cached Key Value map with DataNode.
* Only re-calculate when `flattenOptions` changed.
*/
export default function useKeyValueMap(flattenOptions) {
return React.useMemo(function () {
var cacheKeyMap = new Map();
var cacheValueMap = new Map(); // Cache options by key
flattenOptions.forEach(function (dataNode) {
cacheKeyMap.set(dataNode.key, dataNode);
cacheValueMap.set(dataNode.data.value, dataNode);
});
return [cacheKeyMap, cacheValueMap];
}, [flattenOptions]);
}