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

254
Views
Cómo resolver el tipo 'vacío' no se puede asignar al problema de tipo 'ReactNode' en TSX

Estoy tratando de iterar el elemento MenuItem del componente Mui usando el ciclo forEach , pero obtengo el tipo 'void' no es asignable para escribir el error 'ReactNode' . Aquí está mi fragmento de código-

 <TableCell> <Typography>expiry</Typography> <Select variant="outlined" sx={{ width: '100%', height: 35, borderRadius: 2 }}> { groupData.forEach((option) => ( <MenuItem key={option.expiry} value={option.expiry}> {option.expiry} </MenuItem> ))} </Select> </TableCell>

Gracias de antemano

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

0

forEach devuelve vacío. Para mostrar una lista de elementos en JSX, utiliza el método de map de la matriz, que convertirá los elementos de la matriz en alguna otra forma. Por ejemplo:

 const squares = ( <ul> {[1, 2, 3, 4].map((value) => ( <li key={value}>{value}</li> ))} </ul> );

Obtenga más información sobre las listas en reaccionar aquí

Para tu caso, puedes hacer lo siguiente:

 <TableCell> <Typography>expiry</Typography> <Select variant="outlined" sx={{ width: '100%', height: 35, borderRadius: 2 }}> {groupData.map((option) => ( <MenuItem key={option.expiry} value={option.expiry}> {option.expiry} </MenuItem> ))} </Select> </TableCell>
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!