Search code examples
reactjsmaterial-uiformikformik-material-ui

Set initialValue formik


I am currently using formik to build a form, but when I use nested object inside initialValues like this : address:{title:"this a title",value:{principalAddress:"test",seconderyAddress:""}}

I can't access to principalAdress in formik field when I set the name of the field

<Field component={TextField} fullWidth type="text" name="value. seconderyAddress"/>.

if there s someone who can help me I will be thankful.


Solution

  • Try setting the Field's name to: address.value.principalAddress

    <Field component={TextField} fullWidth type="text" name="address.value.principalAddress"/>