React Native Popup Menu (Auto Generating Options)

Discussion in 'JavaScript' started by iamconnor, Apr 12, 2020.

  1. #1
    Hello, I've made a drop down menu using the
    npm package.
    
             <MenuOptions>
                  <MenuOption value={`test`}>
                   <Text style={styles.menuContent}>test</Text>
                  </MenuOption>
             </MenuOptions>
    
    Code (markup):
    Usually options are set out inside using the
    tag like shown above, that is a working example of an option in the menu. In the class constructor I created an array called
    inside that array I have 3 items. I tried doing a
    for the items in the array then tried adding the
    in hope that It would create options for each of the items in the array, I did this with the code below.
    
    {
      this.state.plates.forEach((test) => {
        <MenuOption value={`${test}`}>
        <Text style={styles.menuContent}>{test}</Text>
       </MenuOption>
      })
    }
    Code (markup):
    Unfortunately, this didn't work (No options were shown in the the menu) and I received no errors.
     
    iamconnor, Apr 12, 2020 IP