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

typo in controlled switch warning hook #991

Open
tomdaniels opened this issue Jul 29, 2023 · 0 comments
Open

typo in controlled switch warning hook #991

tomdaniels opened this issue Jul 29, 2023 · 0 comments

Comments

@tomdaniels
Copy link

tomdaniels commented Jul 29, 2023

❓Question

I think there is a bug in useControlledSwitchWarning that will rendering two different warnings at the same time.

  1. when the component goes from controlled to uncontrolled and,
  2. when the component goes from uncontrolled to controlled.

I believe the first warning condition is incorrect. I would be happy to throw up a PR with the following change:

warning(
  !(isControlled && !wasControlled),
  `\`${componentName}\` is changing from uncontrolled to be controlled. Reach UI components should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled \`${componentName}\` for the lifetime of the component. Check the \`${controlPropName}\` prop.`
);

Hope I'm not missing something blatantly obvious 😓

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

No branches or pull requests

1 participant