FlatList inside ScrollView doesn't scroll
See original GitHub issueEnvironment
Environment:
OS: Linux 4.15
Node: 8.11.2
Yarn: 1.7.0
npm: 5.6.0
Watchman: 4.9.0
Xcode: N/A
Android Studio: 3.1 AI-173.4720617
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4
Description
I’ve 4 FlatList
s with maxHeight
set to 200
inside a ScrollView
.
<ScrollView>
<FlatList/>
<FlatList/>
<FlatList/>
<FlatList/>
</ScrollView>
and when I try to scroll a FlatList
, it doesn’t scroll but the ScrollView
scrolls. How do I fix this issue ?
Full Source Code
import { Component, default as React } from 'react';
import { FlatList, ScrollView, Text } from 'react-native';
export class LabScreen extends Component<{}> {
render() {
return (
<ScrollView>
{this.renderFlatList('red')}
{this.renderFlatList('green')}
{this.renderFlatList('purple')}
{this.renderFlatList('pink')}
</ScrollView>
);
}
getRandomData = () => {
return new Array(100).fill('').map((item, index) => {
return { title: 'Title ' + (index + 1) };
});
};
renderFlatList(color: string) {
return (
<FlatList
data={this.getRandomData()}
backgroundColor={color}
maxHeight={200}
marginBottom={50}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item }) => <Text>{item.title}</Text>}
/>
);
}
}
Reproducible Demo
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
FlatList inside ScrollView doesn't scroll - Stack Overflow
The issue is that the parent component is the only one registering the scroll event. The solution is to contextually decide which component ......
Read more >How to embed a Flatlist inside a ScrollView?? : r/reactnative
You're not supposed to put a FlatList in a ScrollView. If you have a fixed height for your FlatList, it's okay, but Android...
Read more >How to Fix 'VirtualizedLists should never be nested inside ...
VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead. While this ...
Read more >[Solved]-FlatList inside ScrollView doesn't scroll-React Native
Coding example for the question FlatList inside ScrollView doesn't scroll-React Native.
Read more >React-native – FlatList inside ScrollView doesn't scroll
I've 4 FlatList s with maxHeight set to 200 inside a ScrollView . ... and when I try to scroll a FlatList ,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, this solution worked for me.
Does this mean that the Flatlist should be able to scroll if the ScrollView scrollEnabled is hardcoded as false? I can’t seem to get this to work still… i.e