I have created a separate component in which it will render a card with form inside it. I used Formik API to handle it. This is my code.
function ParentComponent(){
return (
<View>
<ChildComponent someDataFromApi={details}/>
</View
)
}
import { Formik } from "formik";
import * as Yup from "yup";
function ChildComponent(){
const someSchema={
firstName: Yup.string().required().label("First Name"),
lastName: Yup.string().required().label("Last Name"),
}
return (
<Formik
initialValues={first_name: details.first_name, last_name: details.last_name, }
validationSchema={someSchema}
onSubmit={(values) => console.log(values)}
>
<Field label={"First Name"} name="firstName">
<Field label={"Last Name"} name="lastName">
</Formik>
}
I don't know why it doesn't show the initialValues for the fields, I tried console logging it and it returns correct values means it already catches the data from initialValues, it just doesn't show it in the field.