Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native tab view inside a scrollview

expo demo

I'm trying to use react-native-tab-view with scrollable content, but having the tabview start half way down a scrollable page like:

    <View style={{flex: 1}}>
      <ScrollView style={{flex: 1}}>
        <SomeContent />
        <TabView
            navigationState={{ index, routes }}
            renderScene={renderScene}
            onIndexChange={setIndex}
            initialLayout={initialLayout}
            style={{flex: 1}}
        />
      </ScrollView>
    </View>

However when I run this on ios nothing renders below the tabs. If I remove the top level scrollview then the whole thing will render but obviously only the tab itself is scrollable.

Any advice would be appreciated

like image 873
user2086359 Avatar asked Nov 04 '25 10:11

user2086359


1 Answers

this issuse almost drove me crazy, this is the solution:

<View style={{flex: 1}}>
      <ScrollView style={{flex: 1}}>
        <SomeContent />
        <TabView
            navigationState={{ index, routes }}
            renderScene={renderScene}
            onIndexChange={setIndex}
            initialLayout={initialLayout}
            style={{height:1000}}
        />
      </ScrollView>
    </View>

add height to your tab view and it would work

like image 149
Curtis Crentsil Avatar answered Nov 07 '25 11:11

Curtis Crentsil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!