useFormik initialValues pass object props

863 views Asked by At

I build a simple project to explain my problem

here the full code

https://codesandbox.io/s/check-it-4d2g1?file=/src/App.tsx:585-598

I want to pass initialValues from App component to Step1 component and after that show the firstName in Step2 component

here my initialValues in useFormik hooks

const formik = useFormik({ initialValues: { firstName: "", lastName: "" } });

This is step 1

here the user fill the firstName input

enter image description here

here the firstName field

enter image description here

This is step 2

image

So how can I displat firstName at Step2 ?

How I try is the right way?

I know there is 3 way for that

1.Passing a component to the component prop of Formik

2.Using the render method and passing your forms markup in JSX

3.Wrap your form with Formik and add your form as JSX

What is the fit way can you fill my codesandbox example according this way...?

https://codesandbox.io/s/check-it-4d2g1?file=/src/App.tsx:585-598

1

There are 1 answers

0
check everytime On

I found solution for that

full code here:

https://codesandbox.io/s/check-it-forked-mp3ux