Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollView not show content React-native

I'm building an application using react-native was all right until I needed to add ScrollView, no matter what screen I add and the content stops being rendered, no error is displayed, whatever is occurring is silent, I've tried Several things I saw on the internet but nothing solved my problem, I put an example code below...

My code:

export default () => (
    <View style={{flex: 1}}>
        <ScrollView style={{flex: 1}}>

             // My page content here

        </ScrollView>    
    </View>
);

Apparently it's something simple but I did not find the solution, if anyone can help me thank you.

like image 546
1fabiopereira Avatar asked Dec 02 '22 13:12

1fabiopereira


2 Answers

The code that fixed this for me was to use contentContainerStyle={{flex: 1}} rather than just style. This sets the flex on the outer container of the scrollview, rather than the inner container.

like image 149
krewllobster Avatar answered Dec 06 '22 11:12

krewllobster


Try adding a height and width to the scroll view's style, and then work your way from there.

Or

make it absolute position and set the top, left, bottom and right position to 0 as such

position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0
like image 33
WilliamC Avatar answered Dec 06 '22 10:12

WilliamC