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

180
Views
¿Cómo escribir renderItem Flatlist recibido por prop en reaccionar nativo y TS?

Tengo un componente HorizontalList que representa esto:

 <HorizontalList data={categories} renderItem={renderCategories} titleList={'Categories'} />

ingrese la descripción de la imagen aquí

este es mi archivo de componentes que recibe los siguientes accesorios

 //HorizontalList.tsx interface Props { titleList: string; data: object[]; renderItem: <--- //IDK what type should be here; } const HorizontalList: React.FC<Props> = ({titleList, data, renderItem}) => { return ( <View style={styles.root}> <Text style={styles.titleText}>{titleList}</Text> <FlatList horizontal data={data} renderItem={renderItem} /> </View> ); };

pero no sé qué tipo debería ser renderItem prop, lo intenté con () => JSX.Element , pero aparece el error:

 Type '({ item }: { item: ICategorieItem; }) => JSX.Element' is not assignable to type '() => Element'.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes hacerlo;

 interface Props { titleList: string; data: ICategorieItem[]; renderItem: ({ item: ICategorieItem, index: number, }) => React.ReactElement; }

o alternativamente, puede hacer uso de ListRenderItem de react-native .

Para más alternativas, por favor vea esta discusión .

 // data prop type definition for FlatList data: ReadonlyArray<ItemT> | null | undefined; // renderItem prop type definition renderItem: ListRenderItem<ItemT> | null | undefined;

Cuando también vea las definiciones de tipo para renderItem y accesorios data , notará que los accesorios de aquellos que reciben exactamente el mismo tipo genérico.

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!