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

gwhite-dayspring picture gwhite-dayspring  路  3Comments

nicolabortignon picture nicolabortignon  路  3Comments

Liqiankun picture Liqiankun  路  3Comments

tokict picture tokict  路  3Comments

kylehagler picture kylehagler  路  3Comments