Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollView disappears along with content when adding flex:1 to contentContainerStyle

Tags:

react-native

When I add a fixed height style it works and the content is there but when I set it to flex:1 (the correct way) the scrollview disappears along with the content.

My code:

<ScrollView contentContainerStyle={{flex:1}} showsVerticalScrollIndicator={false}>
          <View style={{padding: 5}}>
            <Text>search</Text>
          </View>
          <View style={{padding: 5}}>
            <Text>New Matches</Text>
            <ScrollView contentContainerStyle={{flex:1}} horizontal={true} showsHorizontalScrollIndicator={false}>
              <View style={{padding: 10}}>
                <Thumbnail medium circle source={require('../assets/placeholders/profile1.jpg')}/>
                <Text>Christian</Text>
              </View>
              <Text>works</Text>
              <Text>works</Text>
              <Text>works</Text>
              <Text>works</Text>
              <Text>works</Text>
            </ScrollView> 

Also, as you can see I have two scrollviews. I am referring to the outermost (the vertical scrollview).

like image 555
Christian Lessard Avatar asked Apr 08 '18 16:04

Christian Lessard


1 Answers

Wrap your outer ScrollView to a View component with flex:1 style.

<View style={{flex: 1}>
  <ScrollView contentContainerStyle={{flex:1}} showsVerticalScrollIndicator={false}>
...
  </ScrollView>
</View>
like image 54
Hamid Avatar answered Oct 08 '22 02:10

Hamid