HarryChen0506 / react-markdown-editor-lite

a light-weight Markdown editor based on React. 一款轻量的基于React的markdown编辑器
https://harrychen0506.github.io/react-markdown-editor-lite/
MIT License
1.02k stars 161 forks source link

wht I getting this error when i try to write in the editor [object object] #283

Open am0029 opened 1 year ago

am0029 commented 1 year ago

why I getting this error when i try to write in the editor [object object]

i did everthing ok this happens when i want write something into editor just said [object object]

Delwalt commented 1 year ago

Hi @am0029 I am assuming this is because onChange event returns an object and not a value. the object looks like this:

{
        text: string;
        html: string;
}

so you have to make sure when you are setting the state you are actually setting the text as a state and not the complete object.

Maybe updating your code to something like this help:

 <MdEditor onChange={(value) => setEditorValue(value.text)} />