Uncaught TypeError: Cannot read properties of undefined (reading 'replace') in Syncfusion Gantt
Uncaught TypeError: Cannot read properties of undefined (reading 'replace') in Syncfusion Gantt
我在我的应用程序中的一个 React 无状态组件中使用 GanttComponent(来自 @syncfusion/ej2-react-gantt)已经运行了很长时间没有任何问题。
我的队友不断更改应用程序的其他部分(包括 package.json 模块),但我的应用程序中与甘特图相关的任何内容都没有更改,现在我突然从 syncfusion 甘特图的相关供应商处收到此错误文件(更确切地说来自 node_modules@syncfusion\ej2-base\src\util.js 文件)
Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
at setValue (util.js:84:1)
at TreeGrid.TreeGridLocale (treegrid.js:250:1)
at TreeGrid.preRender (treegrid.js:158:1)
at TreeGrid.Component.appendTo (component.js:183:1)
at GanttTreeGrid.renderTreeGrid (tree-grid.js:97:1)
at GanttComponent.Gantt.renderTreeGrid (gantt.js:481:1)
at GanttComponent.Gantt.renderGantt (gantt.js:408:1)
at TaskProcessor.checkDataBinding (task-processor.js:72:1)
at GanttComponent.Gantt.render (gantt.js:340:1)
at GanttComponent.render (gantt.component.js:36:1)
at GanttComponent.Component.appendTo (component.js:185:1)
at GanttComponent.ComponentBase.renderReactComponent (component-base.js:66:1)
at GanttComponent.ComponentBase.componentDidMount (component-base.js:49:1)
at commitLifeCycles (react-dom.development.js:19814:1)
at commitLayoutEffects (react-dom.development.js:22803:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:188:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237:1)
at invokeGuardedCallback (react-dom.development.js:292:1)
at commitRootImpl (react-dom.development.js:22541:1)
at unstable_runWithPriority (scheduler.development.js:653:1)
at runWithPriority (react-dom.development.js:11039:1)
at commitRoot (react-dom.development.js:22381:1)
at finishSyncRender (react-dom.development.js:21807:1)
at performSyncWorkOnRoot (react-dom.development.js:21793:1)
at react-dom.development.js:11089:1
at unstable_runWithPriority (scheduler.development.js:653:1)
at runWithPriority (react-dom.development.js:11039:1)
at flushSyncCallbackQueueImpl (react-dom.development.js:11084:1)
at flushSyncCallbackQueue (react-dom.development.js:11072:1)
at scheduleUpdateOnFiber (react-dom.development.js:21199:1)
at dispatchAction (react-dom.development.js:15660:1)
错误来自某个 setValue 函数,当试图在其第一行调用 nameSpace.replace() 时:
export function setValue(nameSpace, value, obj) {
var keys = nameSpace.replace(/\[/g, '.').replace(/\]/g, '').split('.'); <--this line
// eslint-disable-next-line
var start = obj || {};
// eslint-disable-next-line
var fromObj = start;
var i;
var length = keys.length;
var key;
for (i = 0; i < length; i++) {
key = keys[i];
if (i + 1 === length) {
fromObj[key] = value === undefined ? {} : value;
}
else if (isNullOrUndefined(fromObj[key])) {
fromObj[key] = {};
}
fromObj = fromObj[key];
}
return start;
}
在我收到错误的那一刻,正在从 TreeGrid.prototype.TreeGridLocale(在 @syncfusion\ej2-treegrid\src\treegrid\base\treegrid.js 中调用该函数):
TreeGrid.prototype.TreeGridLocale = function () {
var locale = L10n.locale;
var localeObject = {};
setValue(this.locale, {}, localeObject); <-- this line
var gridLocale;
gridLocale = {};
gridLocale = getObject(this.locale, locale);
var treeGridLocale;
treeGridLocale = {};
treeGridLocale = getObject(this.getModuleName(), gridLocale);
setValue('grid', treeGridLocale, getObject(this.locale, localeObject));
L10n.load(localeObject);
};
如您所见,传递给 setValue 的第一个参数是 this.locale(因为 nameSpace 第一个参数)。
我一直在查看整个 treegrid.js 文件,试图找到 this.locale 应该受到影响的确切位置但我猜不出来。
我想知道什么会影响这些供应商,以至于 this.locale 不会受到适当的影响!
报告的问题仅在语言环境值设置为 null 时重现。我们想知道是否由于相同的原因为您复制了该问题,或者您是否在将区域值设置为 null 后动态更改了区域值。我们要求您设置语言环境值,我们提供了语言环境示例供您参考。
样本:https://stackblitz.com/edit/localization-ptckpw-jwfaqu-86hg2u?file=index.js
我在我的应用程序中的一个 React 无状态组件中使用 GanttComponent(来自 @syncfusion/ej2-react-gantt)已经运行了很长时间没有任何问题。
我的队友不断更改应用程序的其他部分(包括 package.json 模块),但我的应用程序中与甘特图相关的任何内容都没有更改,现在我突然从 syncfusion 甘特图的相关供应商处收到此错误文件(更确切地说来自 node_modules@syncfusion\ej2-base\src\util.js 文件)
Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
at setValue (util.js:84:1)
at TreeGrid.TreeGridLocale (treegrid.js:250:1)
at TreeGrid.preRender (treegrid.js:158:1)
at TreeGrid.Component.appendTo (component.js:183:1)
at GanttTreeGrid.renderTreeGrid (tree-grid.js:97:1)
at GanttComponent.Gantt.renderTreeGrid (gantt.js:481:1)
at GanttComponent.Gantt.renderGantt (gantt.js:408:1)
at TaskProcessor.checkDataBinding (task-processor.js:72:1)
at GanttComponent.Gantt.render (gantt.js:340:1)
at GanttComponent.render (gantt.component.js:36:1)
at GanttComponent.Component.appendTo (component.js:185:1)
at GanttComponent.ComponentBase.renderReactComponent (component-base.js:66:1)
at GanttComponent.ComponentBase.componentDidMount (component-base.js:49:1)
at commitLifeCycles (react-dom.development.js:19814:1)
at commitLayoutEffects (react-dom.development.js:22803:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:188:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237:1)
at invokeGuardedCallback (react-dom.development.js:292:1)
at commitRootImpl (react-dom.development.js:22541:1)
at unstable_runWithPriority (scheduler.development.js:653:1)
at runWithPriority (react-dom.development.js:11039:1)
at commitRoot (react-dom.development.js:22381:1)
at finishSyncRender (react-dom.development.js:21807:1)
at performSyncWorkOnRoot (react-dom.development.js:21793:1)
at react-dom.development.js:11089:1
at unstable_runWithPriority (scheduler.development.js:653:1)
at runWithPriority (react-dom.development.js:11039:1)
at flushSyncCallbackQueueImpl (react-dom.development.js:11084:1)
at flushSyncCallbackQueue (react-dom.development.js:11072:1)
at scheduleUpdateOnFiber (react-dom.development.js:21199:1)
at dispatchAction (react-dom.development.js:15660:1)
错误来自某个 setValue 函数,当试图在其第一行调用 nameSpace.replace() 时:
export function setValue(nameSpace, value, obj) {
var keys = nameSpace.replace(/\[/g, '.').replace(/\]/g, '').split('.'); <--this line
// eslint-disable-next-line
var start = obj || {};
// eslint-disable-next-line
var fromObj = start;
var i;
var length = keys.length;
var key;
for (i = 0; i < length; i++) {
key = keys[i];
if (i + 1 === length) {
fromObj[key] = value === undefined ? {} : value;
}
else if (isNullOrUndefined(fromObj[key])) {
fromObj[key] = {};
}
fromObj = fromObj[key];
}
return start;
}
在我收到错误的那一刻,正在从 TreeGrid.prototype.TreeGridLocale(在 @syncfusion\ej2-treegrid\src\treegrid\base\treegrid.js 中调用该函数):
TreeGrid.prototype.TreeGridLocale = function () {
var locale = L10n.locale;
var localeObject = {};
setValue(this.locale, {}, localeObject); <-- this line
var gridLocale;
gridLocale = {};
gridLocale = getObject(this.locale, locale);
var treeGridLocale;
treeGridLocale = {};
treeGridLocale = getObject(this.getModuleName(), gridLocale);
setValue('grid', treeGridLocale, getObject(this.locale, localeObject));
L10n.load(localeObject);
};
如您所见,传递给 setValue 的第一个参数是 this.locale(因为 nameSpace 第一个参数)。 我一直在查看整个 treegrid.js 文件,试图找到 this.locale 应该受到影响的确切位置但我猜不出来。
我想知道什么会影响这些供应商,以至于 this.locale 不会受到适当的影响!
报告的问题仅在语言环境值设置为 null 时重现。我们想知道是否由于相同的原因为您复制了该问题,或者您是否在将区域值设置为 null 后动态更改了区域值。我们要求您设置语言环境值,我们提供了语言环境示例供您参考。
样本:https://stackblitz.com/edit/localization-ptckpw-jwfaqu-86hg2u?file=index.js