I have a class called Tab
which has three props:
num: string
desc: string
parts: Part[]
where Part
has this code in Tab.tsx
:
JavaScript
x
5
1
interface Part {
2
desc: string,
3
link: string
4
}
5
But when I create a Tab
in Menu.tsx
(the parent), I am unsure how to define the parts attribute.
JavaScript
1
2
1
<Tab num="1" desc="Description" parts=? />
2
How do I go about this?
Advertisement
Answer
parts
is an Array of objects in the shape of { desc: string; link: string; }
.
Pass it this way: [{ desc: "foo", link: "bar" }, { desc: "foo", link: "baz" }]
.
Example:
JavaScript
1
6
1
<Tab
2
num="1"
3
desc="Description"
4
parts={[{ desc: "foo", link: "bar" }, { desc: "foo", link: "baz" }]}
5
/>
6