react native ListView with scrollable content in both vertical AND horizontal doesn't seem to work anymore with react-native 0.28 (react 15.1.0)
See original GitHub issueSince the react-native last release 0.27 > 0.28 (and React 15.0.2 > 15.1.0) a ListView that contain a scrollable content in both vertical and horizontal can now only be scrolled in only one direction:
- if the listView is defined with a flexDirection = “row”, the listView can be scrolled horizontally but rebound back to a fix height position preventing to see what the listView contain down vertically.
- if the listView is defined with a flexDirection = “column”, the listView can be scrolled vertically but rebound back to a fix width position preventing to see what the listView contain horizontally further left. sample:
export default React.createClass({
...
render():View {
return(
<ListView
decelerationRate = "fast"
snapToAlignment = "start"
dataSource = {this.state.dataSource}
style = {styles.listView}
renderRow = {this._getColumn}
initialListSize = {100}
scrollEnabled = {true}
horizontal = {true}
pagingEnabled = {false}
showsHorizontalScrollIndicator = {false}
showsVerticalScrollIndicator = {false}
removeClippedSubviews = {true}
automaticallyAdjustContentInsets = {true}
alwaysBounceVertical = {true}
alwaysBounceHorizontal = {true}
bouncesZoom = {false}
canCancelContentTouches = {true}
centerContent = {false}
directionalLockEnabled = {true}
/>
);
},
...
_getColumn(el:Array<Object>, sectionID:string, rowID:string):View {
return(
<View
key = {"row-`$(sectionID)`:`$(rowID)`"}
style = {styles.column}
>
...
</View>
);
},
...
});
const styles:StyleSheet = StyleSheet.create({
listView: {
position : "relative",
flexDirection : "row", // <---------- 'row' || 'column'
flexWrap : "wrap",
alignSelf : "stretch",
top : 0,
width : 380,
height : 600,
backgroundColor : "transparent",
overflow : "hidden",
},
column: {
flex : 1,
flexDirection : "row",
alignSelf : "stretch",
alignItems : "flex-start",
justifyContent : "flex-start",
backgroundColor : "red",
position : "relative",
width : 380/3,
height : 1250,
},
});
Before, with React 15.0.2 and react-native 0.26 it worked as expected: it was possible to navigate horizontally and vertically in the columns that appeared within the listView.
Is there anything wrong in my way of setting the StyleSheet? I’ve tested a lot of combination so some extra (maybe not necessary) StyleSheet arguments are still in used in styles.listView and styles.column…
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
react native ListView with scrollable content ... - Stack Overflow
react native ListView with scrollable content in both vertical AND horizontal doesn't seem to work anymore with react-native 0.28 (react 15.1.0).
Read more >Common bugs in React Native ScrollView and how to fix them
After putting all those elements inside the ScrollView component, you can use it to scroll through them vertically (the default) or horizontally ......
Read more >ListView - React Native
ListView - A core component designed for efficient display of vertically scrolling lists of changing data. The minimal API is to create a ......
Read more >How to use the FlatList Component — React Native Basics
There have been a quite a few ways to create a scrolling list in React Native, most notably they have been the ScrollView...
Read more >Displaying a List in React Native: Map Method or FlatList ...
FlatList is a React Native component that provides scrolling features by default. The FlatList component comes with: Header, Footer, Horizontal scrolling, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
+1. My example is a bit simpler. I have a scrollview around an image and I am trying to make it scroll in all directions. Before moving to react-native 0.28, it was working fine. Now, its not working.
<ScrollView ref={(scrollView) => { this._scrollView = scrollView; } } directionalLockEnabled={false} horizontal={true} style={{ backgroundColor: '#FFF', flex: 1 }}> <View style={{ marginVertical: 50 }}> <Image source={require('../image.png') }> </Image> </View> </ScrollView>
I’m new to react-native ,meet the same problem,my
ScrollView
can’t work!I’m very depressed! Should I resolve it by revert it to 0.27