Loop through Js Array of objects


#1

Im using a reason component inside my react component and I want to pass an array of objects as props like so

        <Stepper
          orientation="vertical"
          steps={[
            {
              label: "First",
              content: "Hey",
              id: 0
            },
            {
              label: "Second",
              content: "Maybe",
              id: 1
            }
          ]}
        />

The steps props in particular.
Im not sure how to loop over them in the corresponding reason file

Can anyone just create a gist of a file which can loop over the items even if its in li tags. Thanks


#2

How’s this snippet?

The key bit is

      <div>
        (ReasonReact.arrayToElement(
          List.map(
            step => <div>
              (str(step.label ++ ": "))
              (str(step.content))
            </div>,
            steps
          ) |> Array.of_list
        ))
      </div>

#3

This is awesome. It works… Thanks