useFormik vs Formik #2851
-
The docs for useFormik make it seem like I should not be using I personally prefer using Is there a strong reason for me to be using the |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
nevermind, I answered my own question by finally having a reason that required context (using FieldArray) so I can see what it's useful. I still prefer to use useFormik for my simple forms because the code looks cleaner that way |
Beta Was this translation helpful? Give feedback.
-
I was really excited to use formik with hooks, and not the "ugly" syntax: <Formik>(stuff) => (<div>...</div>)</Formik> I find the "function as children syntax" worse because it's less readable, and mainly because it doesn't allow using Formik actions and state outside the JSX (in other hooks). I was really expecting a syntax similar to this: function LoginForm() {
const [FormikLoginCtx, formikLoginProps] = useFormik({ ... });
// or FormikLoginForm, etc
// other hooks...
return (
<FormikLoginCtx>
<Form>
<h3>Hello, my friend. Stay awhile and listen!</h3>
<div>name</div>
<input .../>
</Form>
</FormikLoginCtx>
} @jaredpalmer - what do you think? |
Beta Was this translation helpful? Give feedback.
-
@KutnerUri you can import
and I have no idea why we don't have it in documentation, I'll check if I have some free time for PR export itself - https://github.com/formium/formik/blob/master/packages/formik/src/FormikContext.tsx#L10 |
Beta Was this translation helpful? Give feedback.
-
Well you can't set a context with a hook, yet at least, so you can't really
have one hook to do that
…On Sun, 24 Oct 2021, 19:04 Kutner JS, ***@***.***> wrote:
I know, I just think using a single hook for all would be cleaner
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2851 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIZZ3MKSDTXM6F5QN2LZGZTUIO4ZJANCNFSM4TE7OOOQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
My current approach is to use |
Beta Was this translation helpful? Give feedback.
nevermind, I answered my own question by finally having a reason that required context (using FieldArray) so I can see what it's useful. I still prefer to use useFormik for my simple forms because the code looks cleaner that way