question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

shouldComponentUpdate doesn't respect `null` -> `false` change

See original GitHub issue

false 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:closed
  • Created 7 years ago
  • Reactions:13
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
timhwang21commented, Jan 17, 2017

+1, this is sometimes relevant for checkboxes + radio buttons.

0reactions
lock[bot]commented, May 5, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found