0

I am populating a Select dropdown in a component using this code

export const Dropdown = props => (
  <Select placeholder={props.placeholder} onChange={onChange}>
    {Items.map(item =>
      <option key={item.key} value={item.key}>{item.value}</option>
    )};
  </Select>
)

I want to use this component for different GQL API which returns item with different parameter. Sometimes the item.value is item.foo sometimes item.bar. What I am trying to do, passing a props called parameter so that I can use this parameter in this JSX using props.parameter as foo or bar. So how can I use this item.foo or item.bar (whatever comes from props parameter) instead of item.value? In a nutshell How can I change the value parameter of item.value with a props value?

Devil's Dream
  • 655
  • 3
  • 15
  • 38

0 Answers0