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

TS generic List how can I say now what Items can be?

$
0
0

I have a list component, it works. But my question is, how can I say now which item should have items ?

Like

interface items { name: string; text: string; done: boolean;}

Code:

function UL<T>({ items, render, itemClick }: { items: T[], render: (item: T) => React.ReactNode, itemClick: (id: T) => void }) {  return (<View>      {        items.map((el, i) => (<Pressable key={i} onPress={() => itemClick(el)}>            {render(el)}</Pressable>        ))      }</View>  )}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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