Jest issue TypeError: generateConfig[fn] is not a function
teamco opened this issue · 4 comments
detail: TypeError: generateConfig[fn] is not a function
at /home/frontend/node_modules/antd/node_modules/rc-picker/lib/utils/dateUtil.js:157:35
at Array.forEach (<anonymous>)
at forEach (/home/frontend/node_modules/antd/node_modules/rc-picker/lib/utils/dateUtil.js:153:9)
at /home/frontend/node_modules/antd/node_modules/rc-picker/lib/PickerInput/hooks/useRangePickerValue.js:84:59
at nextCreate (/home/frontend/node_modules/react-dom/cjs/react-dom.development.js:15846:19)
at Object.mountMemo [as useMemo] (/home/frontend/node_modules/react-dom/cjs/react-dom.development.js:16219:16)
at Object.useMemo (/home/frontend/node_modules/react/cjs/react.development.js:1532:21)
at useMemo (/home/frontend/node_modules/antd/node_modules/rc-picker/lib/PickerInput/hooks/useRangePickerValue.js:80:34)
at Picker (/home/frontend/node_modules/antd/node_modules/rc-picker/lib/PickerInput/SinglePicker.js:200:63)
"antd": "^5.13.3",
...
"rc-picker" (in deps): "3.14.6"
It seems like the error with moment.js usage
Uncaught [TypeError: generateConfig[fn] is not a function]
- setMillisecond is not a function.
- getMillisecond is not a function.
`
function fillTime(generateConfig, date, time) {
var tmpDate = date;
var getFn = ['getHour', 'getMinute', 'getSecond', 'getMillisecond'];
var setFn = ['setHour', 'setMinute', 'setSecond', 'setMillisecond'];
setFn.forEach(function (fn, index) {
if (time) {
tmpDate = generateConfig[fn](tmpDate, generateConfiggetFn[index]);
} else {
tmpDate = generateConfig[fn](tmpDate, 0);
}
});
return tmpDate;
}
`
Having the same issue, this seems to be caused by a mismatch of the rc-picker and antd dependency.
Antd uses a version of rc-picker which export a get/setMillisecond method but the specified rc-picker version does not have that method