react-quill icon indicating copy to clipboard operation
react-quill copied to clipboard

False positive "You are passing the delta object from the onChange event back as value"

Open thehappycoder opened this issue 5 years ago • 6 comments

In my case, when both nextContents and this.lastDeltaChangeSet are undefined, I get this error. It happens in a real scenario when I switch between 2 records, and component.js componentWillReceiveProps gets called

From component.js:

if (nextContents === this.lastDeltaChangeSet) {
        console.error(nextContents, this.lastDeltaChangeSet)
        throw new Error(
          'You are passing the `delta` object from the `onChange` event back ' +
            'as `value`. You most probably want `editor.getContents()` instead. ' +
            'See: https://github.com/zenoamaro/react-quill#using-deltas'
        )
      }

React-Quill version

1.3.3

thehappycoder avatar Jul 08 '19 01:07 thehappycoder

PR welcome to add a typecheck

alexkrolick avatar Jul 29 '19 04:07 alexkrolick

Had the same issue, as a workaround I initialize the passed value as an empty String:

constructor() {
  this.state = {
    quillContent: props.value || props.defaultValue || "",
  }
}
 ...

render() {
  return <ReactQuill value={quillContent}/>
}

A value={quillContent || ""} also should work if you're lazy.

Frozen-byte avatar Sep 09 '19 14:09 Frozen-byte

@alexkrolick i would like to take this issue and work on it.

ganeshmani avatar Oct 13 '19 13:10 ganeshmani

<Form.Item initialValue='' name='content' label='内容' rules={[{required: true}]}> <ReactQuill ref={quillRef} theme="snow" value='' modules={_qModules}/> </Form.Item> You need to set an initial value

dashixiong-11 avatar Aug 06 '21 06:08 dashixiong-11

To second the answer of dashixiong-11. You need to set an initial value to ReactQuill component. This worked for me.

<ReactQuill value={props.value ?? ""} /> // This messes up with the entire screen if null or undefined

afrozopsy avatar Jan 10 '22 13:01 afrozopsy

I still have this error:

<ReactQuill value={value || ''} defaultValue='' />

wuliupo avatar May 09 '22 03:05 wuliupo