React-native-swiper: Dynamic Data Not Work Page Nation Image Slider !!!

Created on 10 Sep 2018  ·  2Comments  ·  Source: leecade/react-native-swiper

Which OS Android

Version

Which versions are you using:

  • react-native-swiper v1.5
  • react-native v0.5.4

Im use remote data to load image slider my code but page nation no work when slide image goto last slide :

`const Slide = props => {
return (
)
};
class SliderComponent extends Component {

constructor (props) {
    super(props);  
    this.state = {
        dataSource: [],
        index: 0
    }      
}
componentDidMount() {

    return fetch('http://awebmaker.ir/top_service/Api/Json/getSlider')
        .then((response) => response.json())
        .then((responseJson) => {
            this.setState({
                dataSource: responseJson,
            }, function() {

            });
        })
        .catch((error) => {
            console.error(error);
        });
}

render() {
    return (
        <View style={styles.container}>
            <Swiper
                height={200} autoplay>
                {
                    this.state.dataSource.map((item, index) => <Slide
                        uri={item.image}
                        i={index}
                        key={index} />)                        
                }
            </Swiper>

        </View>
    );
}

}`

Most helpful comment

+1 @awebmaker I'm facing the same issue and the pagination indicator not moving to another dot, the work around is by using conditional rendering to swiper, example...

{this.state.welcomeImage.length > 0 ?
    <Swiper
       autoplay= {true}
       autoplayTimeout= {5}
       paginationStyle= {styles.pagination}
    >
       {this.state.welcomeImage.map((item, index) => {
                return (
                       <View
                               key={index}
                               style= {styles.welcomeImage}
                       />  // and so on...

All 2 comments

+1 @awebmaker I'm facing the same issue and the pagination indicator not moving to another dot, the work around is by using conditional rendering to swiper, example...

{this.state.welcomeImage.length > 0 ?
    <Swiper
       autoplay= {true}
       autoplayTimeout= {5}
       paginationStyle= {styles.pagination}
    >
       {this.state.welcomeImage.map((item, index) => {
                return (
                       <View
                               key={index}
                               style= {styles.welcomeImage}
                       />  // and so on...

+1 How to fix ???

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gwhite-dayspring picture gwhite-dayspring  ·  3Comments

hadrienbbt picture hadrienbbt  ·  3Comments

AndrewSouthpaw picture AndrewSouthpaw  ·  3Comments

itinance picture itinance  ·  3Comments

tibic picture tibic  ·  3Comments