0

I have a form which has initial values.

<Form
  form={form}
  layout="vertical"
  name="form1"
  initialValues={
    {name: ''}     
  }
 />

But i need this form to have conditional initial values. So i could change it with condition. But how can i do it in JSX ?

const [option, setOption] = useState()

  <Form
    form={form}
    layout="vertical"
    name="form1"
    initialValues={
      ( option === 'name' && {
          name: '',
      }),
      { option === 'ocupation' && {
        ocupation: '',
      }),
      { option === 'gender' && {
        gender: '', 
      })
    }
   />

But it didn't work. I tried to play with parantessis. But it also doesnt work. Maybe anyone knows how to make this simple thing work ?

IT DOESNT RELOSLVE MY QUESTION

0 Answers0