Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Jodit-react undefined property "name"

I think Jodit is not handling react event at all?

part of the code:

let [something,setSomething] = useState({'s':''})
let {s} = something
let handleChange = (e)=>{
        setSomething(
            {
                ...something,
                [e.target.name]:e.target.value  //error occuring here.

            }
        )

    }

and then when trying to rendering jsx:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<JoditEditor required className = 's' name='s' value={s} onChange={(e)=>handleChange(e)}></JoditEditor

and in dev browser I get :

enter image description here

as title mentioned, and of course this does not happen with normal html element.

>Solution :

Props of onChange event is string content, not event.
I updated your code.

let [something,setSomething] = useState({s:''})
let {s} = something
let handleChange = (key, newContent)=>{
    setSomething(
       {
          ...something,
          [key]: newContent
       }
    )
}

<JoditEditor
  required
  className = 's'
  name='s'
  value={s}
  onChange={(newContent) => handleChange('s', newContent)}>
</JoditEditor>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading