I’m trying to print, for example, the Names on some in my TSX.
Data has this form :
const targets: {
[key: string]: {
[key: string]: string[]
}
}[] = [
{
'0665496f-7a4e-46b6-a922-2d42ce205c03': {
names: ['Hello', 'World'],
dob: ['1971-09-01'],
},
},
{
'2679d2b8-9c25-44e3-bfad-3e2ef6b93b94': {
names: ['Jordan'],
},
},
{
'8a8b7630-5bc8-443e-a88d-c1601659b39e': {
names: ['John Doe'],
},
},
]
How can I do it the more efficient way ? The code I tried is very complicated, I’m pretty sure I’m doing it wrong…
Here’s what I need for output, for example for the first object :
<div>
<input data-profile-id="0665496f-7a4e-46b6-a922-2d42ce205c03" data-key="names" type="checkbox" />
<label>Hello</label>
</div>
<div>
<input data-profile-id="0665496f-7a4e-46b6-a922-2d42ce205c03" data-key="names" type="checkbox" />
<label>World</label>
</div>
I need this infos in dataset to handle click on those inputs.
Thanks a lot.