react-quill
react-quill copied to clipboard
False positive "You are passing the delta object from the onChange event back as value"
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
PR welcome to add a typecheck
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.
@alexkrolick i would like to take this issue and work on it.
<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
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
I still have this error:
<ReactQuill value={value || ''} defaultValue='' />