react-ace icon indicating copy to clipboard operation
react-ace copied to clipboard

Require is not a function when loading ace editor

Open YoavSimpo opened this issue 5 years ago • 4 comments

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: #

YoavSimpo avatar Dec 30 '19 12:12 YoavSimpo

Pretty sure this means react-ace is unusable in react..... You cannot import the module into a vanilla create react app.

OR13 avatar Jul 10 '20 20:07 OR13

Solution... downgrade to "react-ace": "6.3.2",

OR13 avatar Jul 10 '20 20:07 OR13

@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?

Luxapodular avatar Oct 14 '20 17:10 Luxapodular

你需要先引用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)

carl-lou avatar Apr 14 '22 03:04 carl-lou