Android
Which versions are you using:
If index prop is changed, current swipe-page should be scrolled to the updated page
On initial load Swiper is behave ok, display page that should be displayed by index.
When index updated Swiper doesn't scroll to the new position, despite of fact, that he is receive new offset in the Swiper components
To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.
import React, { useMemo, useRef, useState } from 'react';
import Swiper from 'react-native-swiper'
import { View, Text, Button } from 'react-native';
const ChannelScreen = () => {
const ref = useRef ( null )
const [ index, setIndex ] = useState ( 0 )
const channelsList = useMemo ( () => [ '1', '2', '3', '4' ], [] )
return (
<View style={styles.wrapper}>
<Button
title="Press me"
onPress={() => setIndex ( index + 1 )}
/>
<Swiper loop={false}
ref={ref}
showsButtons={false}
showsPagination={false}
index={index}
>
{
channelsList.map ( ( ch ) => {
return (
<View style={styles.slide1}>
<Text style={styles.text}>{ch}</Text>
</View>
)
} )
}
</Swiper>
</View>
);
};
export default ChannelScreen
const styles = {
wrapper: {
flex: 1,
},
slide1: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#9DD6EB'
},
slide2: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#97CAE5'
},
slide3: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#92BBD9'
},
text: {
color: '#fff',
fontSize: 30,
fontWeight: 'bold'
}
}
-
Here is very basic example.
I have array of channels.
On screen load, i define index based on some parameters, that receive from outside.
On Initial mount, Swiper works ok and display right page based on index.
If i press button, to change index (emulation of index update), i want that Swiper will display new Page based on index.
But this isn`t happen
i got same behavior, using scrollby() method change the index props but dont change the actual swiper view.
Which versions are you using:
react-native-swiper v1.6.0-nightly.5
react-native v0.61.5
issue coming for ios only to me
same issue.
has not it been resolved yet?
only android issue.
any update on this???
Most helpful comment
same issue.
has not it been resolved yet?
only android issue.