Cannot implement shouldComponentUpdate
See original GitHub issueSince renderNode
doesn’t pass down the value
anymore, the recommended way to get it seems to be through editor.value
but that doesn’t work well for shouldComponentUpdate
s. Part of the problem is that editor
is a React component and thus a mutable object, which means the same reference will be passed down and prevProps.editor.value
will always be equal to nextProps.editor.value
because editor.value
is a getter returning editor.state.value
.
For example, let’s imagine a paragraph component with a shouldComponentUpdate
that returns false
if the value didn’t change: reproduction
As you will see, the component is never updated (although the value changes).
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
reactjs - React.Component doesn't implement ... - Stack Overflow
Component doesn't implement shouldComponentUpdate(), but React.PureComponent implements it with a shallow prop and state comparison.
Read more >shouldComponentUpdate doesn't work well if component ...
React's shouldComponentUpdate based performance improvements work great for improving the performance of medium-weight components with large ...
Read more >React.Component
Use shouldComponentUpdate() to let React know if a component's output is not affected by the current change in state or props. The default...
Read more >ReactJS shouldComponentUpdate() Method - GeeksforGeeks
The shouldComponentUpdate method allows us to exit the complex react update life cycle to avoid calling it again and again on every ...
Read more >Optimizing with shouldComponentUpdate | Build with React JS
Notice by implementing shouldComponentUpdate , we are able to avoid rendering (and calling superExpensiveFunction ) when it isn't needed.
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 FreeTop 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
Top GitHub Comments
Okay so I can confirm that passing down value as suggested by Ian is the way to go 💪
@Zhouzi ah actually I meant like so:
Sorry if that wasn’t clear.