-
-
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
Add meta prop to Field, FastField #343
Comments
My plan is to add a |
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal. |
Not using formik anymore, and this was actually one of the reasons for switching. But I believe this is still on the roadmap. Any chance of doing this as part of #828? |
Yes for sure. |
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal. |
Pin |
What about I'd like to validate my field against my schema before the field is touched. |
In the documentation here: (https://jaredpalmer.com/formik/docs/api/fieldarray) it says as of
However, according to this that field is instead earmarked for v2. Is this already available somewhere or is the documentation incorrect? |
It's already in v2. |
Can we not also spread the meta for the field onto the component here: I find it that I have to use the I wasn't understanding the "backwards compat" comment about the legacy |
Yeah I have noticed this myself during v2 usage. |
@jaredpalmer can you help me understand why |
Backwards compat |
can you elaborate? the docs state pretty clearly that |
That must be a bug then. Can you fix in the code? |
It is written incorrectly in the docs. |
meta is not passed to my Input component as props, tried as per document . Since there are many issues are reported, do we have option to access field error in Field rather than look into form error? |
meta should be passed to the component of the field! It contains field-level data and fields need to be able to easily access field-level data. We have Field components that are also used outside of Formik forms. With redux-form, we could easily "plug & play" the required stuff into the field's |
I was pretty surprised myself the
|
Switched to useField for custom components, but lost some time wondering why i'm not getting the meta as described in the docs. This use case should either be removed the docs or get fixed. |
@FREEZX field-level meta should be the second item in the Tuple returned by
If meta, above, is not being passed for you, you should open a new issue. Please include a code sandbox repro if this is the case. The issue above is specifically about |
Sorry, seems like i wasn't clear. First i tried |
Hi, I found this same issue, While if I use It must indicate 2 vars, so the second can be matched with field meta props. Otherwise, I cannot get the correct prop (which is meta.error && meta.touched ) I want to use. |
@flora8984461 you should be able to resolve that warning with the slightly odd syntax: Or you can prefix field with an underscore. Finally, you can either remove the |
@johnrom Thanks a lot! |
Solution form @gordonjl snippet is better than useField, since useField hooks you into context and you'll have problem with unnecessary rerenders. |
V3 will expose I think we should still revisit why fieldMeta isn't being passed automatically, since we have already retrieved that data in |
I'm trying to migrate a big project from redux-form to Formik. This meta field not being present in the custom component, especially while the documentation implies it should be for some reason is really a pain! Also, this issue being open from 2018 really makes me doubt to choose Formik. |
Same thing, migration from redux-form, but workaround from @gordonjl helped to me. Just add |
Documentation really should be changed on this issue... One of the many who has been searching for this thread after digging through the formik source. |
I'm so surprised this hasn't been addressed in over 4 years on such a popular library... is there any plan for implementing this? Maybe in v3? Can we help in any way? It puts a big kink in an otherwise very clean solution with our design system components. |
Hey! I would really love to see this fixed. I might find some spare time to prepare a PR, but wanted to ask first if there is a reason why this is not fixed yet. |
Feature
Current Behavior
<Field>
component, when using with a custom component or render prop, passes down the following structure to the component being rendered:{ field: { name, onBlur, onChange, value }}
. Extraction oftouched
anderror
for a particular field has to be done manually. This becomes quite painful when dealing with deeply nested fields. For instance, when accessingerrors.foo.bar
, one needs first to check the existence oferrors.foo
:errors.foo && errors.foo.bar
.Desired Behavior
Pass down the following structure:
{ field: { error, name, onBlur, onChange, touched, value }}
.Info
There is at least one caveat:
<input>
and other HTML elements should not receive those extra properties. It might make sense to only implement this for render prop.The text was updated successfully, but these errors were encountered: