Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component not reflecting state in store #3061

Closed
helmus opened this issue Jun 14, 2017 · 8 comments
Closed

Component not reflecting state in store #3061

helmus opened this issue Jun 14, 2017 · 8 comments
Labels

Comments

@helmus
Copy link

helmus commented Jun 14, 2017

Are you submitting a bug report or a feature request?

Bug Report

What is the current behavior?

I created a very simple yes / no component mapped to true / false values.
When clicking "No" the value is updated in the store, but the component does not update.
Only after clicking Yes first the component updates when clicking No.

What is the expected behavior?

The component should reflect the store in the state.

Sandbox Link

https://codesandbox.io/s/r06VKjB4K

What's your environment?

redux-form 6.8
redux 3.6
react-redux 5.0.4

Other information

I apologize if this is not a bug, but this seems extremely counter intuitive for users trying to build custom components. My hunch feeling says this is a bug because somewhere the state isn't being strictly compared.

Update:

Adding a formatter or a parser that does nothing ( format={value=>value} ) has a side effect of fixing the problem. This amplifies my feeling that this is in fact a bug.

@erikras
Copy link
Member

erikras commented Jun 15, 2017

It's interesting that if you make the values 0 and 1, it works. So it's not about being "falsy".

@erikras
Copy link
Member

erikras commented Jun 15, 2017

Here's the bug.

I'm trying to figure out why this was written like this.

@erikras
Copy link
Member

erikras commented Jun 15, 2017

This is related to the hotly contested #1762, #1774, and #1993.

I think that @clayne11 is probably correct on this issue. false should be a valid value, and if you need a checkbox to go back to pristine when it gets unchecked, you will have to initialize it to false.

And fixing this will require a breaking change release.

@helmus
Copy link
Author

helmus commented Jun 15, 2017

agree 100% that true, false should be valid values. I also think that null, undefined and '' should be treated as distinct valid values to.

@erikras
Copy link
Member

erikras commented Jun 15, 2017

I also think that null, undefined and '' should be treated as distinct valid values too.

That's a harder case to make, as an empty field comes back as '', and I think it is important for a form with no initial values to still report as pristine if you type into a field and erase the value. This is a personal opinion of mine.

@zcherries
Copy link

I'm also having this problem.

@erikras
Copy link
Member

erikras commented Jul 11, 2017

⚠️ IMPORTANT ⚠️ As of v7.0.0, undefined and false are no longer equal. Read more.

@erikras erikras closed this as completed Jul 11, 2017
@lock
Copy link

lock bot commented Jul 11, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants