我创建了一个FlatList并在Flatlist标头中添加了Dropdown。单击下拉菜单时,打开的很好,但是单击选项时,它会触发列表。
如何解决这个问题呢?提前致谢。
平面清单代码:
<AnimatedFlatList
{...this.props}
data={this._filteredListItems(data)}
ListHeaderComponent={() =>
this._renderListHeader(formattedStartDate, formattedEndDate)
}
renderItem={this._renderItem}
contentContainerStyle={{
flexGrow: 1,
paddingTop: HEADER_HEIGHT - TABBAR_HEIGHT,
marginTop: TABBAR_HEIGHT - 16,
paddingBottom:35,
marginBottom: 35
}}
keyExtractor={(_, index) => String(index)}
stickyHeaderIndices={[0]}
/>
ListHeaderComponent代码:
<CustomSelect
value={this.state.selectedTrxType}
onChange={val =>
{
this.setState({ selectedTrxType: val });
}}
options={Object.keys(transTypeEnum).map(parseTransTypeCode)}
style={{ flex: 1 }}
/>
选项容器使用的样式:
optionsContainer: {
flex: 1,
maxHeight: 180,
backgroundColor: '#fff',
position: 'absolute',
zIndex: 10,
top: 40,
left: 0,
right: 0,
paddingBottom: 8,
borderBottomLeftRadius: 8,
borderBottomRightRadius: 8,
elevation: 2,
shadowColor: '#000',
shadowRadius: 1,
shadowOffset: { width: 0, height: 2 }
}