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

113
Views
Reaccionar: muestra múltiples opciones codificadas en el componente Seleccionar

¿Cómo puedo mostrar la etiqueta de opciones múltiples en mi componente Seleccionar?

Aquí está mi componente:

 <Select id='myID' name='myName'> { ( (localStorage.getItem("localStorageKey").includes("John")) ? <option key=1 value=myFirstValue>Option 1</option> : ` "Something else here" ` ) } </Select>

Hasta ahora, si pongo solo una opción, funciona, pero si agrego otra, diga:

 <Select id='myID' name='myName'> { ( (localStorage.getItem("localStorageKey").includes("John")) ? <option key=1 value=myFirstValue>Option 1</option> + <option key=2 value=mySecondValue>Option 2</option> : ` "Something else here" ` ) } </Select>

No mostrará nada

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

<> <option key=1 value=myFirstValue>Option 1</option> <option key=2 value=mySecondValue>Option 2</option> </>

Envuelve tus opciones como esta

about 4 years ago · Juan Pablo Isaza Report

0

Para tener más de un elemento JSX como hermano, debe estar envuelto en un React Fragment o en una matriz.

<> es una abreviatura de <React.Fragment>

 <Select id='myID' name='myName'> { (localStorage.getItem("localStorageKey").includes("John")) ? <> <option key={1} value="myFirstValue">Option 1</option> <option key={2} value="mySecondValue">Option 2</option> </> : "Something else here" } </Select>

Mediante el uso de matriz,

 [<option key={1} value="myFirstValue">Option 1</option>, <option key={2} value="mySecondValue">Option 2</option>]
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!