I have a JS object myFieldsObj as below;
{
field1: {value: 1},
field2: {value: 2},
field3: {value: 3}
}
In my JSX, I want to iterate over this and render some output.
<MyCustomDialog>
{
<>
Object.keys(myFieldsObj).map((key, index) => {
<div key={index}>
<Field field={myFieldsObj[key]} />
</div>
})
</>
}
</MyCustomDialog>
However the above is giving an error saying
Uncaught ReferenceError: index is not defined
Not sure what the issue is with the syntax.