uiwjs / react-monacoeditor

Monaco Editor component for React.
https://uiwjs.github.io/react-monacoeditor/
MIT License
296 stars 26 forks source link

Cannot read properties of null (reading 'useState') #169

Open stephencharette-old opened 1 year ago

stephencharette-old commented 1 year ago

I am getting this error after I npm install and import MonacoEditor into my react functional component.

This is some of my code: I have version 3.5.8 installed.

`import React, { useState, useContext } from "react"; import MonacoEditor from "@uiw/react-monacoeditor";

<MonacoEditor value={code} language={language} onBlur={handleCodeChange} onChange={handleCodeType} options={{ theme: "vs-dark", }} /> ` No matter what options I pass in, as long as MonacoEditor is there, I get this error:

Cannot read properties of null (reading 'useState') TypeError: Cannot read properties of null (reading 'useState') at useState (http://localhost:3000/static/js/bundle.js:257147:25) at MonacoEditor (http://localhost:3000/static/js/bundle.js:64921:70) at renderWithHooks (http://localhost:3000/static/js/bundle.js:30704:22) at updateForwardRef (http://localhost:3000/static/js/bundle.js:33275:24) at beginWork (http://localhost:3000/static/js/bundle.js:35322:20) at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:20296:18) at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:20340:20) at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:20397:35) at beginWork$1 (http://localhost:3000/static/js/bundle.js:40271:11) at performUnitOfWork (http://localhost:3000/static/js/bundle.js:39518:16)

jaywcjlove commented 1 year ago

@stephencharette There is no way to reproduce your error.

stephencharette-old commented 1 year ago

@jaywcjlove My project is here: https://github.com/stephencharette/_toolkit

If you pull the latest master branch, and try to add the MonacoEditor to client/src/components/Code.js it should give the error

jaywcjlove commented 1 year ago

@stephencharette I can't run your project. Could not reproduce your error.

stephencharette-old commented 1 year ago

Please see my monaco branch, you should now be able to run my project without having any firebase credentials. The issue lies in the Library.js file where I am adding in a MonacoEditor component.