I would like to pass an array of objects from parent component to child component, but when I pass as props
and declare interface on child component with expected types parent component gives error. How can I pass the data?
Here is the code to pass prop to a child called ConsultationCard
else if (check && st.length !== 0) {
return <ConsultationCard itemData={items} />;
}
and parent component giving this error:
Type '({ id: number; title: string; client: string; due: string; count: number; amount: number; method: string[]; material: string[]; status: string; docs?: undefined; } | { id: number; title: string; client: string; ... 6 more ...; count?: undefined; })[]' is not assignable to type 'Data[]'
Child component has this type of interface and prop expectation:
interface Data {
id: number;
title: string;
client: string;
due: string;
count: number;
amount: number;
method: string[];
material: string[];
status: string;
docs?: number | undefined;
}
interface Props {
itemData: Data[];
}