diff --git a/src/index.tsx b/src/index.tsx index a2f6a7c..ea78a6d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -14,10 +14,13 @@ import { GestureResponderEvent, LayoutChangeEvent, ListRenderItemInfo, + Dimensions, } from 'react-native'; import mergeExtraData from './merge-extradata'; const isAndroidRTL = I18nManager.isRTL && Platform.OS === 'android'; +const { width, height } = Dimensions.get('window'); + type Props = { data: ItemT[]; @@ -77,8 +80,8 @@ export default class AppIntroSlider extends React.Component< bottomButton: false, }; state = { - width: 0, - height: 0, + width, + height, activeIndex: 0, }; flatList: FlatList | undefined; @@ -260,8 +263,8 @@ export default class AppIntroSlider extends React.Component< this.props.onSlideChange && this.props.onSlideChange(newIndex, lastIndex); }; - _onLayout = ({nativeEvent}: LayoutChangeEvent) => { - const {width, height} = nativeEvent.layout; + _onLayout = () => { + const { width, height } = Dimensions.get('window'); if (width !== this.state.width || height !== this.state.height) { // Set new width to update rendering of pages this.setState({width, height});