instea/react-native-popup-menu

How to set conditional based menu options for every item in flat list

avi2021 opened this issue · 2 comments

<FlatList
      data={data}
      renderItem={({ item, index }) => (
        <Menu onSelect={value => Alert.alert(value)}>
          <MenuTrigger text={'Select option ' + item.value} />
          <MenuOptions>
            {
             index === 1 && 
             <MenuOption value="A" text="A" />
            }
            {
             index === 2 && 
             <MenuOption value="B" text="B" />
            }
            {
             index === 3 && 
             <MenuOption value="C" text="C" />
            }
        </MenuOptions>
      </Menu>
      )}
      style={{ height: 200 }}
    />

But Last options overrides for all row's It always shows C for 1/2/3 items

@sodik82 Can you please help me

I have tried your example with expo and it looks just fine.

https://snack.expo.io/@sodik82/fascinated-bananas

I don't see any problem with your code (apart from wrong index handling....)