0

How to pass dynamic data in select?

const array=['a','b','c','d'] 
 <Select data={array} 
  selectedIndex={selectedIndex}   
  onSelect={index => setSelectedIndex(index)}> 
   </Select>

Whenever i use

<SelectItem title='Option 1'/> 
<SelectItem title='Option 2'/> 
<SelectItem title='Option 3'/>

it is working fine but when I am using data its not working

Shahanshah Alam
  • 565
  • 7
  • 22

1 Answers1

1

This might help

const array = ['a','b','c','d'];

export const SelectDisplayValueShowcase = () => {

  const renderOption = (title) => (
    <SelectItem title={title}/>
  );

  return (
    <Layout style={styles.container} level='1'>

      <Select
        style={styles.select}>
        {array.map(renderOption)}
      </Select>

    </Layout>
  );
};
Nooruddin Lakhani
  • 7,507
  • 2
  • 19
  • 39