Antd报错Cannot read properties of undefined (reading 'createElement')
1、代码
root = createRoot(document.getElementById("materialCertification")); root.render(<DisplayUI />);
2、报错信息
logger.js:205 Cannot read properties of undefined (reading 'createElement') error @ logger.js:205 _processError @ actionService.js:1233 eval @ actionService.js:822 processQueue @ angular.js:18117 eval @ angular.js:18165 $digest @ angular.js:19284 $apply @ angular.js:19672 eval @ angular.js:21815 completeTask @ angular.js:21445 eval @ angular.js:6911 _splmStatsJsWrapperFunction @ splmStatsJsService.js:126 setTimeout(异步) window.setTimeout @ splmStatsJsService.js:37 Browser.self.defer @ angular.js:6909 timeout @ angular.js:21805 ctrl.checkUrlCommand @ aw.native.sublocation.controller.js:700 eval @ aw.native.sublocation.controller.js:1031 $digest @ angular.js:19284 eval @ angular.js:19604 completeTask @ angular.js:21445 eval @ angular.js:6911 _splmStatsJsWrapperFunction @ splmStatsJsService.js:126 setTimeout(异步) window.setTimeout @ splmStatsJsService.js:37 Browser.self.defer @ angular.js:6909 $evalAsync @ angular.js:19602 eval @ angular.js:17989 scheduleProcessQueue @ angular.js:18165 $$resolve @ angular.js:18192 resolvePromise @ angular.js:18176 resolveFn @ angular.js:18411 eval @ afxImport.js:5216 Promise.then(异步) eval @ afxImport.js:5215 _splmStatsJsWrapperFunction @ splmStatsJsService.js:126 setTimeout(异步) window.setTimeout @ splmStatsJsService.js:37 eval @ afxImport.js:5214 window.afxDynamicImport @ afxImport.js:5211 eval @ bootstrap.js:93 $Q @ angular.js:18418 eval @ bootstrap.js:92 invoke @ angular.js:5240 k @ angular-ui-router.min.js:7 j @ angular-ui-router.min.js:7 eval @ angular-ui-router.min.js:7 resolve @ angular-ui-router.min.js:7 v @ angular-ui-router.min.js:7 z.transitionTo @ angular-ui-router.min.js:7 z.go @ angular-ui-router.min.js:7 _callee$ @ initeSWDmenuService.js:736 tryCatch @ initeSWDmenuService.js:2 eval @ initeSWDmenuService.js:2 eval @ initeSWDmenuService.js:2 asyncGeneratorStep @ initeSWDmenuService.js:2 _next @ initeSWDmenuService.js:2 eval @ initeSWDmenuService.js:2 eval @ initeSWDmenuService.js:2 onClick @ initeSWDmenuService.js:686 eval @ menu.js:76 eval @ useEvent.js:10 eval @ Menu.js:327 eval @ useMemoCallback.js:15 onInternalClick @ MenuItem.js:135 callCallback @ react-dom.development.js:4164 invokeGuardedCallbackDev @ react-dom.development.js:4213 invokeGuardedCallback @ react-dom.development.js:4277 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291 executeDispatch @ react-dom.development.js:9041 processDispatchQueueItemsInOrder @ react-dom.development.js:9073 processDispatchQueue @ react-dom.development.js:9086 dispatchEventsForPlugins @ react-dom.development.js:9097 eval @ react-dom.development.js:9288 batchedUpdates$1 @ react-dom.development.js:26140 batchedUpdates @ react-dom.development.js:3991 dispatchEventForPluginEventSystem @ react-dom.development.js:9287 dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465 dispatchEvent @ react-dom.development.js:6457 dispatchDiscreteEvent @ react-dom.development.js:6430 显示 20 更多框架 显示简略信息 angular.js:15739 TypeError: Cannot read properties of undefined (reading 'createElement') at _callee$ (materialCertificationService.js:22:1) at tryCatch (materialCertificationService.js:2:1) at Generator.eval [as _invoke] (materialCertificationService.js:2:1) at Generator.eval [as next] (materialCertificationService.js:2:1) at asyncGeneratorStep (materialCertificationService.js:2:1) at _next (materialCertificationService.js:2:1) at eval (materialCertificationService.js:2:1) at new Promise (<anonymous>) at Object.eval (materialCertificationService.js:2:1) at Object.initmaterialCertification (materialCertificationService.js:19:1) 'Possibly unhandled rejection: {}'
问题原因:
把React 从中括号中移除!