开发者问题收集

react-monaco-editor 停电... TypeError: 无法读取未定义的属性“pushUndoStop”

2021-02-02
2634

我在我的项目中使用了 "react-monaco-editor"

import { MonacoDiffEditor } from 'react-monaco-editor';

...

<MonacoDiffEditor
  width="1140"
  height="520"
  language="javascript"
  theme="vs-dark"
  original={this.props.original}
  value={this.props.current}
  options={{
    renderSideBySide: true,
  }}
  editorDidMount={this.editorDidMount}
/>

只有在部署我的服务器后才能查看此错误。

simpleWorker.js:25 Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq el @ simpleWorker.js:25 simpleWorker.js:28 You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker el @ simpleWorker.js:28 react-dom.production.min.js:5058 TypeError: Cannot read property 'pushUndoStop' of undefined at l.value (diff.js:283) at ls (react-dom.production.min.js:5163) at react-dom.production.min.js:6408 at t.unstable_runWithPriority (scheduler.production.min.js:309) at Ui (react-dom.production.min.js:2816) at Cl (react-dom.production.min.js:6204) at cl (react-dom.production.min.js:5895) at react-dom.production.min.js:2851 at t.unstable_runWithPriority (scheduler.production.min.js:309) at Ui (react-dom.production.min.js:2816) rs @ react-dom.production.min.js:5058

我在本地使用 nginx 进行测试,但只记录了 serviceWorker 警告。 我认为 ServiceWorker 警告是我服务器中的 http 环境。

什么是 pushUndoStop... 我真的不知道这个错误。 帮帮我……

1个回答

不确定您是否已经修复了这个问题,因为已经有一段时间了,但万一其他人遇到这个问题,我也遇到了这个问题。我有 monaco-editorv0.20.0v0.35.0 react-monaco-editor ,它们运行良好。然后我更新到 v0.23.0 ,我遇到了这个问题,因为它是回归问题。然后我尝试了 v0.25.2 ,没有任何变化。之后我尝试将 react-monaco-editor 更新到 v0.43.0 ,问题不再发生!我认为这是一个问题,他们在 monaco-editor 中做出了更改,如果你没有将 react-monaco-editor 更新到较新的版本,它就会出现该错误。

Jeremy
2021-07-12