ForEach loop won't dynamically add entries

24 views Asked by At

I am creating a filter with select options for my application. The issue I am encountering is that the select options won't populate when running a nested for loop.

When I specify a certain index, those options will populate for one entry but not all of them.

Code

                {props.headers.map((header, entriesIndex) => (
                  <Select
                  label={header}
                  value={value}
                  onChange={setValue}
                  placeholder="Enter value..."
                  width={300}
                  >
                  // When specifying the specific entry the data will load into the 
                     correct boxes
                  <SelectOption value={"test"} label={props.data[1][entriesIndex]} />

                  // When doing a for loop like this, I am able to log the entries but 
                     actually specifying all the entries the options don't populate 

                  {props.data.forEach((entries, valuesIndex) => {
                    console.log(entries[entriesIndex])
                    // <SelectOption value={entries[entriesIndex]} label= 
                        {entries[entriesIndex]} />
                  })}
                  </Select>
              ))};

There has be something wrong with my nested loop but I am unsure if thats the case or something else is going on.

0

There are 0 answers