我有这个应用程序,我正在用 react-native 编写,我有这个屏幕,它显示大约 50-100 个图像和一些与它们相关联的操作按钮,包括一个弹出菜单(与每个相关联的一个)。有没有办法可以对所有图像使用相同的弹出菜单(相同的实例)?
<View>
// react-native-paper Card Component
<Card style={styles.card}>
<Card.Content style={styles.cardContent}>
<Card.Cover
style={{ height: 60, width: 60 }}
source={
item.avatar ||
(item.gender === 'male'
? require('../../assets/male.jpeg')
: require('../../assets/female.jpeg'))
}
/>
<Caption style={styles.title}>{item.name}</Caption>
</Card.Content>
<Card.Actions>
<Avatar.Text
style={{ backgroundColor: 'skyblue' }}
size={24}
label={`#${item.id}`}
/>
// react-native-paper Menu Component
// can i somehow use a single component for all cards?
<Menu
visible={this.state.visible}
onDismiss={this._closeMenu}
anchor={
<IconButton
icon="menu"
theme={theme}
size={20}
onPress={() => console.log('Pressed')}
/>
}
>
<Menu.Item onPress={() => {}} title="Item 1" />
<Menu.Item onPress={() => {}} title="Item 2" />
<Divider />
<Menu.Item onPress={() => {}} title="Item 3" />
</Menu>
</Card.Actions>
</Card>
.
.
//same card multiple times
.
.
</View>