React-native-swiper: when I wanted to change autoplay, it doesn't work

Created on 18 Sep 2017  ·  7Comments  ·  Source: leecade/react-native-swiper

Which OS ?

android,ios

Version

Which versions are you using:

  • react-native-swiper 1.5.10?
  • react-native v0.43.1

Expected behaviour

Want to control swiper's autoplay at any time

Actual behaviour

Only changed once, again changed swiper no response

How to reproduce it>

this.state={
swiperAutoplay:true
}

autoplayTimeout={4}
loop={true}
autoplay={this.state.swiperAutoplay}
>
Opacity:
this.setState({
swiperAutoplay: !this.state.swiperAutoplay
});
then swiperAutoplay = false,
and swiper does not scroll automatically,

but Opacity angin:
then swiperAutoplay = true,
swiper still does not scroll automatically,

Most helpful comment

You should set autoplay={true} before this.swiper.autoplay(). Like that this.setState({ swiperAutoplay: true }, () => { this.swiper.autoplay() ;})

All 7 comments

You can use <Swiper ref={node => this.swiper = node} />. And after that this.swiper.autoplay()

@ifours
ref={node => this.swiper = node}
autoplayTimeout={4}

                            autoplay={false}
                        >

this.swiper.autoplay()
this isn't work

You should set autoplay={true} before this.swiper.autoplay(). Like that this.setState({ swiperAutoplay: true }, () => { this.swiper.autoplay() ;})

@ifours Thank you very much!

First of all, many Thanks!!
Second, what are the difference betweens the codes:

Code 1: - WORKS:
this.setState({autoPlay:true},() => { this.swiper.autoplay() ;})

Code 2: - Not Works:
this.setState({autoPlay:true})
this.swiper.autoplay();

???

@roysG in first case you will call autoplay after swiper receives autoplay={true}

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndriiBoiko picture AndriiBoiko  ·  3Comments

itinance picture itinance  ·  3Comments

AndrewSouthpaw picture AndrewSouthpaw  ·  3Comments

tibic picture tibic  ·  3Comments

commit-master picture commit-master  ·  3Comments