How do we get hold of index while looping a collection in scalajs-react component? So basically I have code like this:
<.div(
employees.map( employee =>
<.form(
<.label("Name of the employee:",
<.input(^.`type` := "text", ^.cls := "form-control",
^.value := employee.name)),
<.br,
<.label("Addresses:",
<.input(^.`type` := "textarea", ^.rows := 100, ^.cols := 20,^.cls := "form-control",
^.value := employee.addresses.mkString(",")))
)
)
)
So if user changes a field, I need to know which employee in the employees is changed. So I need to know the corresponding index OR if there is some other better way.