shouldComponentUpdate doesn't respect `null` -> `false` change
See original GitHub issuefalse
is a valid field value. If you initialize your form field to null
, then updating to false
doesn’t re-render the form, even though the value did change.
The problem seems to be in
shouldComponentUpdate
: https://github.com/erikras/redux-form/blob/master/src/reduxForm.js#L251
it is using deepEqual
(https://github.com/erikras/redux-form/blob/master/src/structure/plain/deepEqual.js#L5) to
check if the value had changed.
I’m curious why this decision was made, and if it should be updated to recognize changes from null
to false
(and vice-versa), or at least document somewhere that the initial value needs to be undefined
or you will get unexpected behavior.
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:13
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Can shouldComponentUpdate returning false clobber a ...
My hypothesis is that even though render has been called and would render what I want, react receives another state change before the...
Read more >React lifecycle methods: An approachable tutorial with ...
Within this lifecycle method, you can return a boolean — true or false — and control whether the component gets rerendered (e.g., upon...
Read more >General Props | Docs and API Reference
When this is specified as true , after an edit is complete, the grid will automatically receive focus. If set to false ,...
Read more >React.Component
An update can be caused by changes to props or state. These methods are called in ... render() will not be invoked if...
Read more >Writing Resilient Components
It lulls me into a false sense of accomplishment without improving my code. ... Our rendering result should respect changes to props.
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
+1, this is sometimes relevant for checkboxes + radio buttons.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.