-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Pass onChange/onBlur/value/name props directly to Field component instead of passing a field props #1340
Comments
This change would make Formik incompatible with React Native. React Native's TextInput component signature for onChange is |
@Andreyco Why ? Can you give an example ? First of all, that's not true : it's Then, even if it was
And have to use
This code will still work if we merge my suggestion. |
@VincentLanglet You should have to use the render function the way you described your "fix" the first time.
|
@johnrom I agree I can use the render function and create a custom Component wrapper ; and I will do it if the suggestion is not accepted.
That's what I'm asking for. An evolution of the API described by Formik. Cause, since the solution
could avoid to create wrapper, I was thinking it could be a good option to implement in Formik, without negative effect. You could still use |
Field's All other components are custom implementations (own code, 3rd party packaged) and it is impossible to make any library compatible with all other code in the wild. It is developers responsibility to write glue layer between Field and components of choice. I believe Field API was/is right choice and allows it to create compatibility layers for any components. Even React Native, which is in no way DOM based. https://codesandbox.io/s/zrl24rvjw3 Proposed change is definitely breaking change. Not sure if creating, eg. |
@Andreyco I'm not asking to be compatible with all other code in the wild. Just library which also use the "correct" (HTML compatible) props. I think this two implementations should be available.
Another option can be something like this,
|
It already is compatible with intrinsic elements/components such as |
@Andreyco I think there is a misunderstanding between us. I never talk about guessing expected props.
The specificity of my With the change I propose :
|
See #1371 |
@VincentLanglet |
🚀 Feature request
Current Behavior
Is not working, instead I have to do
Desired Behavior
Suggested Solution
Actually, Field, FastField, etc are build this way.
This means
CustomComponent
have to use a propsfield
and a propsform
to work withField
.But some of them, like Material-UI component have well-named props (
onChange
,value
andname
) and could work directly if we passed...field
instead offield
as props.Plus, I don't think coherent the fact we pass
...field
in case ofcomponent === 'string'
and we pass...bag
in case ofCustomComponent
.So, what about something like this (less breaking change)
Or this (no duplicate props but breaking changes)
Describe alternatives you've considered
I know [formik-material-ui] exist https://github.com/stackworx/formik-material-ui
But I think it's sad to write adaptator for every
material-ui
component.And this little change could avoid the use of a new library. (Less is better)
The text was updated successfully, but these errors were encountered: