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

React: A component is changing an uncontrolled input of type checkbox to be controlled. #12201

Closed
DaleSeo opened this issue Aug 22, 2020 · 2 comments

Comments

@DaleSeo
Copy link
Contributor

DaleSeo commented Aug 22, 2020

Describe the bug

When no default value is specified for a prop of type boolean (PropTypes.bool) in args, a warning, A component is changing an uncontrolled input of type checkbox to be controlled. appear in the browser console when toggling the prop on the Controls panel.

This warning doesn't occur when you provide the boolean prop with a value in args.

import React from "react";

import Radio from "./Radio";

export default {
  title: "Components/Radio",
  component: Radio,
  args: {
    label: "Remember me",
    // disabled: false, // The error doesn't occur with this
  },
};

export const Default = (args) => <Radio {...args} />;

image

Expected behavior

There should be no warning when toggling a boolean control.

System:

Environment Info:

  System:
    OS: macOS 10.15.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm
  Browsers:
    Chrome: 84.0.4147.135
    Firefox: 76.0.1
    Safari: 13.1.2
  npmPackages:
    @storybook/addon-a11y: 6.0.16 => 6.0.16 
    @storybook/addon-essentials: 6.0.16 => 6.0.16 
    @storybook/addon-knobs: 6.0.16 => 6.0.16 
    @storybook/addon-links: 6.0.16 => 6.0.16 
    @storybook/addon-storysource: 6.0.16 => 6.0.16 
    @storybook/addons: 6.0.16 => 6.0.16 
    @storybook/react: 6.0.16 => 6.0.16 
    @storybook/theming: 6.0.16 => 6.0.16 

Additional context
Add any other context about the problem here.

@DaleSeo
Copy link
Contributor Author

DaleSeo commented Aug 22, 2020

This issue seems to be related to the Vue issue #11839.

@shilman
Copy link
Member

shilman commented Aug 22, 2020

Thanks! Closing this as a dupe to #10967

@shilman shilman closed this as completed Aug 22, 2020
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

2 participants