Formik: is there an example to use Redux useSelector & useDispatch hoooks?

Created on 29 Jul 2019  路  6Comments  路  Source: formium/formik

鉂換uestion

is there an example to use Redux useSelector & useDispatch hooks with Formik?

Most helpful comment

Okay, if I understand correctly your need here is an example of use of Redux inside the Formik form : https://codesandbox.io/s/holy-water-bci7v

Basically Formik render attribute can take a Functionnal Component in which you can use any hook. You can also use useFormik hook instead of <Formik> or withFormik to maximize hooks.
I hope it answers your question. If not, I think I did not understand the issue

All 6 comments

Hi,
Formik does not require redux to work. What do you want to do exactly with Redux and Formik together ?

I am using redux connect to mapStateToProps and mapDispatchToProps to use dispatch methods from props and also use redux store inside formik form (e,g, I am using list of States in drop down box inside formik form and that list of States is coming from redux store). I am using container with using redux connect and component with form itself. Using redux hooks will allow to remove connect with mapping and make code shorter.

Okay, if I understand correctly your need here is an example of use of Redux inside the Formik form : https://codesandbox.io/s/holy-water-bci7v

Basically Formik render attribute can take a Functionnal Component in which you can use any hook. You can also use useFormik hook instead of <Formik> or withFormik to maximize hooks.
I hope it answers your question. If not, I think I did not understand the issue

Yes, looks like it is what I was looking for... thanks

I am using redux connect to mapStateToProps and mapDispatchToProps to use dispatch methods from props and also use redux store inside formik form (e,g, I am using list of States in drop down box inside formik form and that list of States is coming from redux store). I am using container with using redux connect and component with form itself. Using redux hooks will allow to remove connect with mapping and make code shorter.

Can you please help me with this. I am facing a situation where I'm receiving some data from api I need to load up the same and I'll select the value.id will load up another select form data from which we can access using the value.id.
I need to do the same in formik. Plaease help me. ASAP

Can you please help me with this. I am facing a situation where I'm receiving some data from api I need to load up the same and I'll select the value.id will load up another select form data from which we can access using the value.id.
I need to do the same in formik. Plaease help me. ASAP

what kind of help are you looking for?I was not able to use hooks but with connect it works perfectly fine ...

Was this page helpful?
0 / 5 - 0 ratings