This is my Formik
form that I want to validate with yup
{
"images": [],
"fundingGoal": 1337,
"name": {
"en": "english name",
"fr": "french name"
},
"description": {
"en": "english project desc",
"fr": "french project desc"
},
"country": "Anguilla",
"city": "city",
"address": "address",
"location": "",
"socialMedia": "facebook",
"contact": "contact",
"currency": "USD",
"sdgs": [
"NO_POVERTY"
]
}
My current yup
schema:
const ProjectInputSchema = yup.object().shape({
id: yup.string(),
name: yup.object().shape({
en: yup.string().required(),
fr: yup.string()
}),
description: yup.object(),
images: yup.array(),
...
});
How I render my form with the name
object:
<Form.Group as={Col} md={{span: 5}} controlId="projectName">
<Form.Label>
{t('projectName')}
</Form.Label>
{
<Form.Control
type="text"
name="name.en"
value={(values['name'] as I18n).en}
onChange={handleChange}
/>
}
...
As soon as I type a character into name
or description
, I get the following console error:
Uncaught (in promise) Error: Objects are not valid as a React child (found: object with keys {fr}). If you meant to render a collection of children, use an array instead.
I followed the example implementation (https://codesandbox.io/s/y7q2v45xqx) for nested object but I do not see a difference.