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

143
Views
¿Por qué los niños en mi React.FC no están definidos?

Tengo un contenedor de columna que acepta niños:

 const ThreeColumnWrapper: React.FC = (props) => { const { children } = props; const itemLength = React.Children.count(children); const isOdd = IsOdd(itemLength); const { isCompact } = MediaQuery(); return ( <Base> {React.Children.map(children, (child, index) => { return ( <> {isCompact && isOdd && index === 0 ? ( <Full>{child}</Full> ) : ( <ThreeByTwo>{child}</ThreeByTwo> )} </> ); })} </Base> ); };

Lo mapeo así:

 const columnComponentMap = { 3: ThreeColumnWrapper };

y en mi grilla lo llamo::

 const CategoryGrid: React.FC<PropType> = (props) => { const { categories, columns } = props; const Component = columnComponentMap[columns]; return ( <Component> {categories.map((category, index) => { <ImageCard key={index} imageURL={category.image} linkURL={category.url} title={category.title} aspectRatio="1_1" />; })} </Component> ); };

En mis datos de categorías tengo 7 ítems pero cuando llegan a mi Wrapper solo me sale indefinido, ¿por qué?

Imagen del resultado:

ingrese la descripción de la imagen aquí

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

0

 <Component> {categories.map((category, index) => { // Missing return here return <ImageCard key={index} imageURL={category.image} linkURL={category.url} title={category.title} aspectRatio="1_1" />; })} </Component>

Te perdiste una devolución.

Es un error fácil de cometer con .map() una de las razones por las que prefiero los retornos implícitos cuando solo tengo una sola instrucción

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!