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

fix(FormGroup): dont pass switch prop to tag #2415 #2416

Merged
merged 3 commits into from Apr 13, 2022

Conversation

mikegoatly
Copy link
Contributor

@mikegoatly mikegoatly commented Dec 10, 2021

  • Bug fix
  • New feature
  • Chore
  • Breaking change
  • There is an open issue which this change addresses
  • I have read the CONTRIBUTING document.
  • My commits follow the Git Commit Guidelines
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • My change requires a change to Typescript typings.
    • I have updated the typings accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Fixes #2415 - I also noticed that the typings didn't include the switch prop, so I've added it for completeness.

@@ -30,16 +30,17 @@ const FormGroup = (props) => {
inline,
floating,
tag: Tag,
switch: switchProp,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave this as switch instead of switchProp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not - doing so means you end up with ambiguity between the switch variable and JavaScript switch/case statement - I can call it something else if you'd prefer, e.g. _switch?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, It would be nice to see this ugly error message fixed.
Maybe a comment to explain the variable name would be good to approve this merge?
The other way is to keep the props.switch notation?
Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't leave it as props.switch - destructuring the prop like this fixes the issue - without it switch remains in the attributes object that is passed through to the underlying control.

As I say, I'm very happy to use whatever name is deemed appropriate, but as far as I know this PR hasn't even been looked at by any of the maintainers, so I don't think that's what's causing it to be left unmerged.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workaround: you can remove the switch prop from FormGroup and replace with the bootstrap classname:
<FormGroup className="form-check form-switch">

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had forgotten to respond, the PR looks good 👍

@davidacevedo davidacevedo merged commit 714d557 into reactstrap:master Apr 13, 2022
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

Successfully merging this pull request may close these issues.

FormGroup: Using switch prop results in warning: Received true for a non-boolean attribute switch
4 participants