I have a functional component like
function ItemList({ items }: ItemProps[]) {
return <p>items[0].name</p>
}
and I'm creating it like:
<ItemList items={items} />
items is an array of objects like [{name: 'a' id:0}, {name: 'b' id:1}].
Everything is working, but in ItemList.jsx TypeScript is telling me Property 'items' does not exist on type 'ItemProps[]'
itemsdoesn't exist onItemProps[], because that's an array. It doesn't even exist on the things in the array. Also thepropsargument is always an object, not an array. Did you mean{ items: ItemProps[] }?Something[], because it is always an object, and never an array. Arrays can be passed within the props object. I think what you should do is{ items }: { items: ItemProps[] }.function ItemList(props: { items: ItemProps[] })With destructuring, you'll still need theitems:key.