-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Calls to EditorView.update are not allowed while an update is in progress #280
Comments
I didn't reproduce your error. @Yijx |
Hi,it still has error, let me list the detailed steps Thanks for your help |
@Yijx This may be a CM6 internal bug. I've released a new version that blocks the Ctrl+f shortcut. But that didn't really solve the problem. |
react-codemirror/src/useCodeMirror.ts Lines 60 to 79 in 6bdc5c8
@Yijx This is a really bad way. |
@Yijx This is probably the best solution. import React, { useEffect, useState } from "react";
import CodeMirror from "@uiw/react-codemirror";
import { javascript } from "@codemirror/lang-javascript";
export default function App() {
const [a, setA] = useState(0);
const [extensions, setextensions] = useState([]);
useEffect(() => {
setextensions([javascript({ jsx: true })]);
}, []);
return (
<div>
{a}
<CodeMirror
value="console.log('hello world!');"
height="200px"
extensions={extensions}
onChange={(value, viewUpdate) => {
console.log("value:", value);
}}
onBlur={() => setA(a + 1)}
/>
</div>
);
} |
I have the same problem using '@uiw/react-codemirror' in version 4.7.0, when I try to setStae in 'onBlur'. |
@lililo111 You can try the following method <CodeMirror
- onBlur={() => setA("1")}
/> import * as events from '@uiw/codemirror-extensions-events';
function App() {
const eventExt2 = events.content({
focus: (evn) => {
console.log('focus');
},
blur: (evn) => {
console.log('blur');
},
});
return (
<CodeMirror
value="console.log('hello world!');"
height="200px"
extensions={[
eventExt2,
]}
/>
);
} |
I set onBlur function on CodeMirror and change state (cursor is in edit box), at same time I use command+f to get a search box,CodeMirror will tell me 'Error: Calls to EditorView.update are not allowed while an update is in progress'.
I think it is update conflict?
You can use this demo
https://codesandbox.io/embed/react-codemirror-example-codemirror-6-forked-xx4qvz?fontsize=14&hidenavigation=1&theme=dark
The text was updated successfully, but these errors were encountered: