Skip to content

typo in controlled switch warning hook #991

Open
@tomdaniels

Description

❓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 😓

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions