So im trying to get monaco to work with react and electron, and it loads the loader file, but its stuck on loading. the init function doesnt run console.log the promise with the monaco instance. What am i doing wrong?
import React, { useEffect, useRef, useState } from "react";
import Editor, { monaco } from "@monaco-editor/react";
const path = window.require("path");
function ensureFirstBackSlash(str) {
return str.length > 0 && str.charAt(0) !== "/" ? "/" + str : str;
}
function uriFromPath(_path) {
const pathName = path.resolve(_path).replace(/\\/g, "/");
return encodeURI("file://" + ensureFirstBackSlash(pathName));
}
function App() {
useEffect(() => {
monaco.config({
paths: {
vs: uriFromPath(path.join(__dirname, "node_modules/monaco-editor/min")),
},
});
monaco.init().then((monacoInstance) => console.log(monacoInstance));
}, []);
return (
<div>
<Editor width="500" height="500" language="javascript" value={""} />
</div>
</div>
);
}
export default App;