Issue
array type looks like MyType: {name: string, age: number}[], props type in component is the same
<Content data={arrOfObj} /> // warning
const Content: React.FC<MyType> = (data) => {...}
how to pass it into component correctly? and I also think in the component prop type actually is not equal to MyType. To get access to data you need to write the following data.data, but because of ts thinks data is an array, you can`t write in this way
Solution
This is probably what you wanted
<Content data={arrOfObj} /> // warning
const Content: React.FC<{ data: MyType }> = ({ data }) => {...}
Answered By - Konrad Linkowski
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.