-
Notifications
You must be signed in to change notification settings - Fork 192
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 because this.cursorPos is undefined #3
Comments
@stiang thank you for opening this up! Yup, this indeed appears to be a blatant bug and I have removed the initial check for |
Thanks, that worked! I haven’t had time to look deeply at the page scrolling issue yet, but it was still there with 0.0.10, at least. Have you tried to have multiple |
@stiang thanks for the feedback and sharing more details on this secondary issue! I indeed get the page jump you describe when I have enough instances on the page. This side effect seems to have been introduced from the fix I implemented for #1 - specifically, preserving and setting the cursor position. The page is jumping down because it's trying to set the cursor for the last instance, even if untouched and is internally at 0,0. Without a change, there is a workaround currently but I'm not thrilled with it. If you specify However, let me know if the cursor position is something you can't be without and I'll try my best to overhaul a solution for everyone. Thanks again for your help on these! |
First of all - thanks for stepping up now that react-codemirror appears to be unmaintained!
I get an error when I include a
<CodeMirror>
element. The reason appears to be thatthis.cursorPos
is undefined, but is still being used as an argument forthis.editor.setCursor()
.Looking at the source, it will indeed be undefined if the first outer
if
statement doesn’t trigger, but the second outer does:I was able to solve this by initializing
this.cursorPos
in componentDidMount:At this point the library appears to work, but I encountered another problem (the page scrolls down whenever the prop that controls the editor value is changed, on a page with multiple editors), but I’ll file that as a separate issue if it turns out to be related to the library.
The text was updated successfully, but these errors were encountered: