Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
How to use conditional value in jsx not in OBJECT

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!