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

183
Views
¿Cómo puedo establecer el valor de un Form.Item sin un objeto de formulario en Ant.Design?

Tengo un componente de elemento de formulario personalizado y quiero agregar una entrada oculta, pero no puedo actualizar el valor sin el objeto Ant Form (Form.useForm();

 const selectBefore = ( <Select onChange={value => {/*HOW TO SET NEW VALUE FOR <Input name='term-type'/> ?*/}} > <Select.Option value="date">Date</Select.Option> <Select.Option value="number">Number</Select.Option> </Select> ); const InputType = termType === 'date' ? DateInput : Input; return ( <> <InputType addonBefore={selectBefore} {...rest} /> <Form.Item name='term-type' initialValue={termType} style={{display: 'none'}} > <Input type="text" value={termType} /> </Form.Item> </> );
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede eliminar la parte de entrada por completo en lugar de mantenerla oculta para usar su valor. Prueba esto:

 <Select onChange={value => setTermType(value)}}> <Select.Option value="date">Date</Select.Option> <Select.Option value="number">Number</Select.Option> </Select>

Luego puede usar termType como estado, y se actualizará a medida que cambie el valor de Select . Le sugiero que agregue un marcador de posición o un valor inicial predeterminado a Select componente como

 <Select defaultValue="date" onChange={value => setTermType(value)}}> <Select.Option value="date">Date</Select.Option> <Select.Option value="number">Number</Select.Option> </Select>
about 4 years ago · Juan Pablo Isaza Report

0

Puede usar useState hook y establecer el valor en el state y no usar Form.useForm() y Form.Item en absoluto:

 const [ termType, setTermType ] = useState(""); ... <Select onChange={value => setTermType(value)}}> <Select.Option value="date">Date</Select.Option> <Select.Option value="number">Number</Select.Option> </Select> ... <Input type="text" value={termType} />
about 4 years ago · Juan Pablo Isaza Report
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!