-
-
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
[V2] useFormikContext doesn't return valitationSchema as expected #2092
Comments
+1 Same is for connect() - not returning validationSchema too! It was important for me to mark required fields with hint, depending on schema - now i can't find any way to get it! |
+1 for connect() too, to put asterik on required fields |
@jaredpalmer it appears as though resolving this would give back a very simple workaround for #1241 and #712 Would you accept a PR on this, or is it all hands on v3 for now? |
Hello! Any news on this? Thanks! |
Hi there, I connect my component but when checking for errors, it always returns an empty object. Same goes with useFormikContext.
However, when I console.log(formik), it does return errors. Last but not least, when I type in a username and console log again formik, the errors still contain an error message regarding the username field... Not sure what I am missing here... Thanks any help!
|
Actually my bad, I realized that I should not combine Formik and useFormik. Using Formik fixed that issue with empty error object. |
Hi, any workarounds for this? I also need it to mark required fields with asterisk in custom form fields with formik |
Any update or workaround for this issue? Our current setup does not allow for prop drilling. |
Well, the Formik Docs say the context returns formik/packages/formik/src/Formik.tsx Lines 949 to 987 in e677bea
Its a question of passing the props to the context object: validateOnChange,
validateOnMount,
validate: props.validate,
validationSchema: props.validationSchema
};
return ctx;
} |
This is resolved (I think) in the v3 PR #3231 using the separate hook
|
Oooh! Glad to know v3 is set to fix this. Do you know an ETA for v3? |
No clue; I opened the above PR, but I am not a maintainer. |
Probably safe to say it won't be merged in given the PR was 2 years ago |
I moved to React Hook Form |
I did as well, very similar API and a lot more performant but I'm noticing they are missing the same feature, although it looks like there was discussion on it in the past month so that's promising. If you're interested in having them work on it you should upvote the post, along with the related issue. That seems to be the main way they prioritize work |
I'm getting re-render loops when using |
Never mind - as per usual, it was my own fault that had nothing to do with Formik. Carry on. |
🐛 Bug report
The documentation says that the returned value from useFormikContext is the same as the
formik
props ofconnect
, that includesvalidationSchema
. Also the type definition asserts thatuseFormikContext
return value includesvalidationSchema
, but in effect it currently doesn`t.Current Behavior
useFormikContext
return value does`t includsvalidationSchema
Reproducible example
Iinclude the following test in the source code
The test fails
Expected behavior
The test should pass.
Suggested solution(s)
PR #2090 fixes the issue
Your environment
The text was updated successfully, but these errors were encountered: