uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.17k stars 156 forks source link

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined #125

Closed EOengineer closed 3 years ago

EOengineer commented 3 years ago

I'm running into a strange issue here where the following console error is thrown anytime I modify the value feeding the MDEditor component. The component continues to function normally, just lots of console noise.

handleKeyDown.js:25 Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
    at handleKeyDown.js:25
    at onKeyDown (Textarea.js:41)
    at HTMLUnknownElement.callCallback (react-dom.development.js:191)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:240)
    at invokeGuardedCallback (react-dom.development.js:293)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:308)
    at executeDispatch (react-dom.development.js:393)
    at executeDispatchesInOrder (react-dom.development.js:418)
    at executeDispatchesAndRelease (react-dom.development.js:3303)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3312)

Code:

import MDEditor, { commands } from '@uiw/react-md-editor';
interface PropTypes extends RouterProps {}

const MyForm: FunctionComponent<PropTypes> = (props: PropTypes) => {
  const [item, setItem] = useState({title: "", body: ""})

  return (
            <MDEditor
              height={200}
              value={insight.body}
              onChange={(value) => {
                setItem(prevState => {
                  return { ...prevState, body: value}
                })
              }}/>
  )
};

Anyone else running into this? Im hitting this on the 3.0.0-beta.1 release. I have not tried going back to older releases.

jaywcjlove commented 3 years ago

@EOengineer The latest version 3.0.0-beta.1 Have you confirmed your version?

EOengineer commented 3 years ago

@jaywcjlove I've updated my original report and confirmed Im using the 3.0.0-beta.1 release.

pro-Nate commented 3 years ago

@EOengineer I am experiencing this too on 3.0.0-beta.1. @jaywcjlove With very basic config as above, throws the exact same error on every key press.

jaywcjlove commented 3 years ago

@EOengineer @pro-Nate Upgrade + @uiw/react-md-editor@3.0.0-beta.2

jaywcjlove commented 3 years ago

https://codesandbox.io/s/markdown-editor-for-react-125-dxskk?file=/index.js

EOengineer commented 3 years ago

Can confirm this is fixed. Thanks @jaywcjlove!