-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Wrong type of container
returned from useCodeMirror
#474
Comments
@yifanwww thx! Upgrade |
@yifanwww I haven't solved the problem. I tried to fix the code, but it caused the useCodeMirror hook to fail to update the container, resulting in a rendering failure of the interface. |
The only thing we can do to fix the issue, I think, is just changing the type. We cannot change the logic, as the first time the container changes from - container: editor.current,
+ container: editor.current ? editor.current : undefined, This change will disable the second render, so in I don't know how to improve it, I didn't find a better way... |
Oh maybe we can follow the doc https://github.com/uiwjs/react-codemirror#support-hook useEffect(() => {
if (editor.current) {
setContainer(editor.current);
}
}, [editor.current]); In this |
I tested it and there are still issues even with multiple state updates within the useCodeMirror hook. |
In the document/README, it says the type of container returned from
useCodeMirror
is:However, in the latest version (v4.19.9), the actual type that is exported from the npm package is:
I checked the source code, and I believe the type in document is right.
The source code
props.container
is actuallynull
which is the initial value of the refeditor
inReactCodeMirror
.This change triggers a second render, because the new value
null
is different from the current valueundefined
.HTMLDivElement
and pass it tocontainer
again, triggering a third render.container
finally becomesHTMLDivElement
.During the whole process, the
container
value is actuallyundefined
->null
->HTMLDivElement
.The text was updated successfully, but these errors were encountered: