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

checked: true throws error #8

Open
mastef opened this issue Jun 5, 2018 · 8 comments
Open

checked: true throws error #8

mastef opened this issue Jun 5, 2018 · 8 comments
Assignees

Comments

@mastef
Copy link

mastef commented Jun 5, 2018

The demo code creates this error when isChecked is set to true :

        this.state = {
          data: [
              {
                  id: 1,
                  name: 'Parent A'
              },
              {
                  id: 2,
                  isChecked: true, // <--
                  isExpanded: true,
                  name: 'Parent B'
              }
          ]
        }

React DOM error :

Warning: Failed prop type:
You provided a `checked` prop to a form field without an `onChange` handler.
This will render a read-only field. If the field should be mutable use `defaultChecked`.
Otherwise, set either `onChange` or `readOnly`.

image

@azizali azizali self-assigned this Jan 23, 2019
@eulertour
Copy link

I see this error whether isChecked is true or false.

@ghost
Copy link

ghost commented Jul 25, 2019

How can I decide this problem? :(

@sametsunman
Copy link

I got error, too

@silavsale
Copy link

I have the same error, do you have some solution?

@jarlah
Copy link

jarlah commented Oct 23, 2019

I suppose it works because it catches the actual click event. But i thought checboxes always need onChange.

                <input
                    type="checkbox"
                    name={node[keywordLabel]}
                    onClick={(e) => {
                        this.handleCheckToggle(node, e);
                    }}
                    checked={!!node.isChecked}
                    id={node.id}
                />

@jarlah
Copy link

jarlah commented Oct 24, 2019

#35

@mastef
Copy link
Author

mastef commented Oct 24, 2019

@azizali that doesn't really seem like an enhancement, more of a bug if the demo code produces errors. I guess what I was asking for in the first place was either a fixed demo code

@jarlah
Copy link

jarlah commented Oct 24, 2019

There is no enchancement that can be done in demo code to remove this error. Its a bug and a natural react error that stems from lack of an onChange handler when value is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants