I have implemented Yup + Formik in React Native for form handling.
I have title and body input field in form. Validation errors with title is being displayed but no error message related to body is displayed.
const ReviewSchema = yup.object(
{
title: yup.string().required().min(2),
},
{
body: yup.string().required().min(3),
}
);
function Adddata() {
return (
<View>
<Formik
initialValues={{ title: "", body: "" }}
validationSchema={ReviewSchema}
onSubmit={(v) => {
console.log(v);
}}
>
{(props) => (
<View>
<TextInput
value={props.values.title}
onChangeText={props.handleChange("title")}
/>
<Text>{props.errors.title}</Text>
<TextInput
value={props.values.body}
onChangeText={props.handleChange("body")}
/>
<Text>{props.errors.body}</Text>
</View>
)}
</Formik>