uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.65k stars 132 forks source link

TypeError: Cannot read properties of null (reading 'set') #568

Closed zjy365 closed 1 year ago

zjy365 commented 1 year ago

Here's how I use it

            <CodeMirror
              extensions={[StreamLanguage.define(yaml)]}
              width="100%"
              height="100%"
              minHeight="1200px"
              onChange={debounce(onYamlChange, 1000)}
            />

my version

    "@codemirror/language": "^6.8.0",
    "@codemirror/legacy-modes": "^6.3.3",
    "@emotion/react": "^11.10.6",
    "@emotion/styled": "^11.10.6",
    "@kubernetes/client-node": "^0.18.1",
    "@next/font": "13.1.6",
    "@tanstack/react-query": "^4.24.10",
    "@uiw/react-codemirror": "^4.21.9",

When I mouseover this editor section, the console output is consistent. this error

image
jaywcjlove commented 1 year ago

@zjy365 Can you provide me with a reproducible example using https://codesandbox.io? I can help you troubleshoot the issue.

zjy365 commented 1 year ago

@jaywcjlove I created a new next project and tried it. You can take a look. https://codesandbox.io/p/sandbox/xenodochial-robinson-9yfw8c

jaywcjlove commented 1 year ago
image

There are no errors when downloading the project locally.

image image

@zjy365 So, I cannot reproduce your error.

noa24 commented 1 year ago

i also have the same issue

zjy365 commented 1 year ago

The mouse needs to move within this area to trigger the 'mousemove' event, or if there is any input in the editor, it will trigger the 'error' event mentioned above.

image

@jaywcjlove

chenbinli-dev commented 1 year ago

i have the same issuse☹️

jaywcjlove commented 1 year ago

https://github.com/uiwjs/react-codemirror/assets/1680273/c1b29a5a-1a1d-4b90-b2d2-61202adccf9b

https://github.com/uiwjs/react-codemirror/tree/master/example/nextjs

I recreated the nextjs project and the error disappeared.

@codercoin98 @zjy365 @noa24

se1phine commented 1 year ago

image

zlytxx commented 1 year ago

i have the same issuse too, only set the onChange props will show

zlytxx commented 1 year ago

image https://uiwjs.github.io/react-codemirror/#/theme/data/copilot the demo has same error

kohloth commented 1 year ago

I am having this same issue too. It seemed to start happening recently (I think) but downgrading the version number does not seem to have fixed the problem. These errors come up when moving the mouse over the code mirror input and when pressing keys inside of it. I've tried to see if I can make the error go away by simplifying my use of the component, but even after stripping it down to the bare minimum props (shown below) I still see these console errors.

My usage of the component (note that I've commented most props out - errors still occur)

    <CodeMirror
        ref={rootRef}
        // indentWithTab={false}
        // readOnly={usedReadOnly}
        className="code-input__input"
        // theme={theme}
        value={value}
        height="100%"
        // extensions={extensions}
        onChange={handleChange}
        // basicSetup={basicSetup}
    />

Error is the same as the others have reported:

Screenshot from 2023-09-21 01-18-18

jaywcjlove commented 1 year ago

@zjy365 @kohloth @liaoyingtao This is caused by the integrated crosshairCursor Extension. I have already set it to false by default.

Upgrading to v4.21.15 or using the following configuration can suppress the error caused by the crosshairCursor. The issue related to crosshairCursor needs to be resolved by the @codemirror team.

<CodeMirror 
  basicSetup={{
+   crosshairCursor: false
  }}
 />
mojiAh commented 1 year ago

Had same issue, for now setting the crosshairCursor: false fixed the issue.

zjy365 commented 1 year ago

@zjy365 @kohloth @liaoyingtao This is caused by the integrated crosshairCursor Extension. I have already set it to false by default.

Upgrading to v4.21.15 or using the following configuration can suppress the error caused by the crosshairCursor. The issue related to crosshairCursor needs to be resolved by the @codemirror team.

<CodeMirror 
  basicSetup={{
+   crosshairCursor: false
  }}
 />

Thank you. Successfully resolved