Change value prop not works
See original GitHub issueconst [text, setText] = useState('')
const onTextChange = (textTyped) => {
textTyped = (textTyped.split(' ').length > 3) ? `${textTyped.split(' ').splice(0, 3).join(' ')}</p>` : textTyped
console.log('textTyped', textTyped)
setText(textTyped)
}
<ReactQuill
theme="snow"
value={text}
onChange={onTextChange}
modules={reactQuillModules}
formats={reactQuillFormats}
className="mb-4"
/>
How you can see here (https://i.imgur.com/wFkYMDB.png), above React Quill state text is working fine (it was cut to 3 words), but value prop it’s not updated.
_Originally posted by @gleidsonh in https://github.com/zenoamaro/react-quill/issues/588#issuecomment-643687425_
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Component not updating when I change the props that I pass ...
A component only updates once either its state changes or its props change. A state is a variable or set of variables which...
Read more >Why React Child Components Don't Update on Prop Changes
In React, it's a common problem to have child components that don't re-render when you expect them to. In particular, a common problems...
Read more >Lifting State Up - React
Let's see how this works step by step. First, we will replace this.state.temperature with this.props.temperature in the TemperatureInput component. For now ...
Read more >How to update a component's prop in ReactJS — oh yes, it's ...
This setup works in most of the scenarios. But what if you need to update the prop of the child component, and the...
Read more >Component prop not changing when select value changes ...
Coding example for the question Component prop not changing when select value changes-Reactjs.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello there @gleidsonh!
I have played with the reproduction – the issue here is that calling
setText
with the same value it has at that moment does not trigger a prop update. This is the behavior of thesetState
hook.Until Quill offers a way to prevent edits (as explained in the README), unfortunately there’s not much that can be fixed on ReactQuill’s side.
However, you can easily modify your example, like this, which will work because a new object doesn’t
===
the previous one, even if the contents are the same:The same issue still exists. Why was it closed?