White-screen in Android when wrapping Swiper with a ScrollView
I have a ScrollView around the Swiper component in order to have a "refreshControl". This runs fine on iOS, but not on Android.
This is reproduced in this snack https://snack.expo.io/Sy2nReYMN (toggle OS in the bottom right corner)
Expo SDK 32 react-native-swiper 1.5.14
Had the exact same issue. For some reason this doesn't support an auto height if in a scroll view.
Have to set a hard height value in the style props for the
Had the exact same issue. For some reason this doesn't support an auto height if in a scroll view.
Have to set a hard height value in the style props for the
Setting an explicit height (not %, not flex) on the Swiper component seems to make the content visible.
The height can be set to Dimensions.get("window").height for example, but this is not really desirable since an existing header's height then needs to be subtracted.
modified your code and got it to work by setting the height dynamically, this works but not if the content exceeds the screen, I'm having a separate issue trying to measure the height of the swiper children wrapped inside a scrollview.
import React, { Component } from 'react';
import { Alert, RefreshControl, SafeAreaView, ScrollView, StyleSheet, Text, View } from 'react-native';
import Swiper from 'react-native-swiper';
export default class App extends Component {
constructor(props){
super(props);
this.state = {
isRefreshing: false,
screens: ["Hello swiper", "Beautiful", "And simple"],
height: -1,
width: -1
};
this.measureLayout = this.measureLayout.bind(this);
}
measureLayout({ nativeEvent }) {
const height = nativeEvent.layout.height;
const width = nativeEvent.layout.width;
this.setState({ height, width });
}
onRefresh = async () => {
this.setState({isRefreshing: true})
setTimeout(() => this.setState({isRefreshing: false}), 1500);
};
render() {
return (
<ScrollView
onLayout={this.measureLayout}
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={this.onRefresh} />
}>
<Swiper height={this.state.height} style={{}} showsButtons={false} loop={false}>
{this.state.screens.map(screen => (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#9DD6EB'}} key={screen}>
<Text style={{color: '#fff', fontSize: 30, fontWeight: 'bold'}}>{screen}</Text>
</View>)
)}
</Swiper>
</ScrollView>
);
}
}
have you found a solution?
@ethanyuwang I had the same issue, i fixed it by upgrading react-native-swiper from 1.5.6 to 1.6.0-rc.3