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

Add a way to avoid magically passing props to inputs #189

Open
danielweinmann opened this issue Apr 11, 2023 · 3 comments
Open

Add a way to avoid magically passing props to inputs #189

danielweinmann opened this issue Apr 11, 2023 · 3 comments

Comments

@danielweinmann
Copy link
Contributor

Today, all inputs, selects, text areas, etc. that match child.type === Input (or Multiline, or Select, etc) will receive a bunch of props.

The problem is that React's type comparison is very loose. So, if your component is roughly the same type, it will receive the props. For instance, if you run the array of strings example without customizing the form's inputComponent to something other than input, it will pass unnecessary props to the tags input and mess up the behavior (thanks Chi on Discord for providing the example :D).

I don't have any solid idea of how to address this. Maybe we could check the child's props and see if there are any clues that this is a custom component (value, defaultValue, name, etc.), and if that's the case, we don't do our magic. But this doesn't feel much better than the current behavior to me.

I'd appreciate suggestions :)

cc @diogob @gustavoguichard

@danielweinmann
Copy link
Contributor Author

Another idea is to compare child.type.name with Input.name etc. I don't think it would change the behavior, though. Just throwing ideas around :)

@danielweinmann
Copy link
Contributor Author

In the meantime, anyone running into issues with custom components just needs to make sure their custom components are of a different type than their inputComponent, multilineComponent, etc.

@gustavoguichard
Copy link
Contributor

Interesting! I'd take a look at react-is package and its source to find out the best way to do those checks.

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

2 participants