0

I am working on reactjs and i am using nextjs framework, Right now i am working on "update module"(blog update) using "QuillNoSSRWrapper editor" so right now i am showing user value with "value" tag (value={value}) but then i am unable to type/change anything in editor (something wrong with onchange), How can i fix this ? Here is my current code

const [value, setValue] = useState('');
<QuillNoSSRWrapper modules={modules} onChange={setValue} theme="snow" value={value} />
Maria
  • 43
  • 3
  • 1
    You probably want `onChange={(event) => setState(event.target.whatever)}` to set the value of the element instead of storing an entire event object. – Karolis Dec 14 '22 at 07:20
  • 1
    ``` console.log('onChange Data', e)} theme="snow" value={value} />``` Using this please check and verify the console log is showing just the contents as a string and not a complete event object. – Hari HKH Dec 14 '22 at 07:23
  • Yeah, as @Karolis and @Hari HKH mentions, the value you need is somewhere in the event. If you pass `setValue` without giving it an argument, `e` will be passed to it, which is probably the whole event – Mads Akselsen Dec 14 '22 at 07:24
  • @Karolis : can you please change/update in my code, i am new in Reactjs so i can check at my side – Maria Dec 14 '22 at 07:24
  • Furthermore, I would recommend warpping the `setValue` inside a handler function as discussed here: https://stackoverflow.com/questions/62597532/pass-setstate-as-props-or-create-a-handle – Mads Akselsen Dec 14 '22 at 07:27
  • @MadsAkselsen I am new in Reactjs , can you please update in my code so i can check at my side – Maria Dec 14 '22 at 07:34
  • I need more info to make an attempt, but maybe this article can be of help? https://progressivewebninja.com/how-to-use-react-quill-with-nextjs/ – Mads Akselsen Dec 14 '22 at 07:57
  • @MadsAkselsen actually Right now i can do one thing 1) Either can update something in editor and send value but then by default value (user value using "value={value}) not working 2) Either can show by default value but then cant type anything Hope you understand my point – Maria Dec 14 '22 at 08:03
  • I can see you're code should be correct, so it must be an error somewhere else. Can you share your repo or code somehow? I need some more context – Mads Akselsen Dec 14 '22 at 08:50

0 Answers0