react-ace
react-ace copied to clipboard
Require is not a function when loading ace editor
Problem
We are using react-ace embedded in other sites, we got an error when ace library is already being used, the root cause is the line "ace.acequire = (window as any).ace.require || (window as any).ace.acequire;" inside getAceInstace in editorOptions.ts after this line in ace.tsx there is a call to ace.require Changing the ace.acequire = to ace.require = will fix it.
I got function is not defined. I think this issue in the ace library is the same - https://github.com/ajaxorg/ace/issues/3320 Wanted to fix it myself but didn't have permissions to push.
Detail the problem here, including any possible solutions.
Sample code to reproduce your issue
References
Progress on: #
Pretty sure this means react-ace is unusable in react..... You cannot import the module into a vanilla create react app.
Solution... downgrade to "react-ace": "6.3.2",
@securingsincity I'm also having this issue after recently upgrading to 9.1.4. Any idea on how to fix this in a create-react-app project?
你需要先引用AceEditor(You need to reference AceEditor first) import AceEditor from "react-ace";
然后再引用(And then import) import "ace-builds/src-noconflict/mode-json"; import 'ace-builds/src-noconflict/theme-github';
他们之间有顺序先后关系(There is a sequential relationship between them)