我无法获得嵌套'要滚动的FlatList。我通过传递scrollEnabled = {false}来禁用父FlatList滚动,但这没有效果。我认为父FlatList正在拦截滚动事件,我无法在网上找到任何可能的解决方案。
export const createStyles = () => {
return {
baseStyles: {
height: 70,
overflow: 'hidden',
width: 200,
paddingHorizontal: 5,
borderWidth: 2,
borderColor: StyleConst.colors.grey.lighter3,
borderRadius: 3,
},
};
};
export const createItemStyle = (index, len) => {
console.log(index, len);
if (index !== len - 1) {
return {
borderBottomColor: StyleConst.colors.grey.lighter2,
borderBottomWidth: 1,
width: 150,
}
}
}
export class Dropdown extends Component {
static propTypes = {
data: arrayOf(object),
handleChange: func,
valueExtractor: func.isRequired,
}
renderItem = (item) => {
return (
<TouchableWithoutFeedback onPress={() => this.props.handleChange(this.props.valueExtractor(item))}>
<View key = {item.id}>
<Text>
{item.item.value}
</Text>
</View>
</TouchableWithoutFeedback>
)
}
render() {
const styles = createStyles();
return (
<View style={styles.baseStyles}>
<FlatList
data={this.props.data}
renderItem={this.renderItem}
keyExtractor={this.keyExtractor}
onScrollBeginDrag={() => console.log("start")}
/>
</View>
)
}
}
&#13;