Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to typing renderItem Flatlist received by prop in react native and TS?

$
0
0

I have a component HorizontalList that render this:

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

enter image description here

this is my component file that receives the following props

//HorizontalList.tsxinterface 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>  );};

but I dont know what type should be renderItem prop, I tried with () => JSX.Element , but in I get the error:

Type '({ item }: { item: ICategorieItem; }) => JSX.Element' is not assignable to type '() => Element'.

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>