Using your data structure, your Dropdown component works if you do it this way but would only pick the first option.
const Dropdown = ({ value, index }) => {
return (
<Select>
<option value="1">{value[`option${index+1}`]}</option>
</Select>
);
};
But this is what I advise, If this is within your control, I would advise you restructure your types data structure a little bit to something like below
const types = [
{
id: "1",
name: "color",
options: [
{value: "red", label: "red"},
{value: "blue", label: "blue"}
],
price: 12
},
{
id: "2",
name: "weight",
options: [
{value: "", label: "Placeholder"},
{value: "20", label: "20 Kilos"},
{value: "30", label: "30 Kilos"},
{value: "40", label: "40 Kilos"},
{value: "50", label: "50 Kilos"}
],
price: 13
}
];
Then your dropdown component can also be refactored to this
const Dropdown = ({ options, index }) => {
return (
<Select>
{options.map((option) => <option value={option.value}>{option.label}</option>)}
</Select>
);
};
This would enable you to easily use your Dropdown component with the type array as follows
return (
<MainContainer>
{types.map((value, index) => (
<Dropdown options={value.options} index={index} />
))}
</MainContainer>
);