I am wanting to create a FlatList inside of the ScrollView Component but I kept getting the error "VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead." This led me to this article. I was able to alter my code to the point below, but I am not sure how to alter the this.refs.myList.scrollProperties.offset
to fit my code. Is this the best way to try and go about putting a FlatList inside a ScrollView or is there a better way?
const [enableScrollViewScroll, setEnableScrollViewScroll] = useState(true);
return (
<View
onStartShouldSetResponderCapture={() => {
setEnableScrollViewScroll(true);
}}>
<ScrollView
scrollEnabled={enableScrollViewScroll}>
<Component/>
<View
onStartShouldSetResponderCapture={() => {
setEnableScrollViewScroll(false);
if (this.refs.myList.scrollProperties.offset === 0 && enableScrollViewScroll === false) {
setEnableScrollViewScroll(true);
}
}}>
<FlatList
data={myData}
renderItem={({item}) => (
<Text style = {{
borderWidth: 1,
marginTop: 5,
borderRadius: 3,
paddingLeft: 3,
}}>
{item.content}
</Text>
)}/>
</View>
</ScrollView>
</View>
);