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

[Checkbox] Warning: either controlled or uncontrolled #4413

Closed
wzup opened this issue Jun 2, 2016 · 4 comments
Closed

[Checkbox] Warning: either controlled or uncontrolled #4413

wzup opened this issue Jun 2, 2016 · 4 comments
Labels
component: checkbox This is the name of the generic UI component, not the React module!

Comments

@wzup
Copy link

wzup commented Jun 2, 2016

I use Checkbox with checked prop. I do not have any defaultChecked props set on the component. Why do I see this warning? When I comment out checked prop no warnings are throws. How to get rid of it? I need to use checked prop.

My component.

import Checkbox from 'material-ui/lib/checkbox';

                <Checkbox
                    label={i18n[this.props.data.label]}
                    onCheck={this[this.props.onCheck]}
                    checked={this.props.data.checked}
                    disabled={this.props.data.disabled}
                />

Warning: Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both)

@nathanmarks
Copy link
Member

@wzup what is the starting value of this.props.data.checked?

@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@oliviertassinari oliviertassinari added the component: checkbox This is the name of the generic UI component, not the React module! label Dec 18, 2016
@teknologist
Copy link

teknologist commented Jan 18, 2017

Same here.

 <Checkbox
                      label="Editable"
                      checked={this.props.editable}
                      onCheck={this.props.toggleEditable}
 />

I update the editable prop from the parent component.
When I toggle, I get the warning.

Everything works as expected though

@oliviertassinari
Copy link
Member

@teknologist What value are you providing at the initial render?

@oliviertassinari oliviertassinari changed the title [Checkbox] Warning: Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both) [Checkbox] Warning: either controlled or uncontrolled Feb 12, 2017
@oliviertassinari
Copy link
Member

We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it.
Still, we will accept PR fixes until v1-beta takes over the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: checkbox This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

4 participants