Problem
Couldn't load worker, JSON syntax validation doesn't work. I see Could not load worker warning in the browser console.
Also, I tried to import the json worker
import "ace-builds/src-noconflict/worker-json";
and got the error
TypeError: Cannot read property 'window' of undefined
Sample code to reproduce the issue
import React from "react";
import ReactDOM from "react-dom";
import AceEditor from "react-ace";
import "ace-builds/src-noconflict/ace";
import "ace-builds/src-noconflict/mode-json";
import "ace-builds/src-noconflict/theme-github";
let text =
'{\n "id": 0,\n ' +
'"script": """\n function add(x, y) {\n return x + y;\n }\n add(1, 2);\n """' +
',\n "descr": "add two numbers"\n}';
function App() {
return (
<div className="App">
<h1>Code Editor Demo</h1>
<AceEditor
mode="json"
theme="github"
onChange={(value, stat) => {
console.log("onChange", value, stat);
}}
value={text}
name="UNIQUE_ID_OF_DIV"
editorProps={{ $blockScrolling: true }}
/>
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
References
Codesandbox https://codesandbox.io/embed/ace-worker-3-vrr68
Problem
Couldn't load worker, JSON syntax validation doesn't work. I see
Could not load workerwarning in the browser console.Also, I tried to import the json worker
and got the error
Sample code to reproduce the issue
References
Codesandbox https://codesandbox.io/embed/ace-worker-3-vrr68