My use-case
I want to end up with several forms on one page to update each nested child record, so my first attempt was to List.map
over the children and output input elements, but how might I pass the input element to which child item my input box relates to? If I could pass my map function an index it’d all be fine
Wondering what the ‘best practice’ way of updating a nested list of records might be — a typical parent/child example JSON might be:
{
"parents": [
{
"id": "0001",
"children": [
{
"desc": "Description", "attr": "val", ... etc
},
{
"desc": "Description 2", "attr": "val 2", ... etc
}
]
},
]
}
I can see how you’d do this by giving each child record an ID and then doing an update based a filtered list (and similarly if it was more of a flat, relational database style where each child item had a reference to the parent id and their own id attribute).
Should I be looking to map that JSON to some different structure, perhaps giving each child item an index
attribute to then use as if the source JSON gave each record it’s own ID, or some other way?