React-slick: getting current slide index

Created on 9 Feb 2017  路  2Comments  路  Source: akiran/react-slick

i was wondering if there is any way to get the current slide index?

Most helpful comment

Try this solutions:
on component create method for example

nextClick: function(e){
//alert('next');
console.log(e);
}

on render function I added like this
render: function() {
.....

var settings = {
dots: false,
infinite: true,
speed: 500,
swipeToSlide: false,
arrows: true,
slidesToShow: 2,
afterChange: this.nextClick,
slidesToScroll: 2
};

return ()
}

And I got on console 2 4 6 8 10 (Because I show 2 slider Item in one time
And you can keep from "e" variable current Slider Item

I hope it's help you

All 2 comments

Try this solutions:
on component create method for example

nextClick: function(e){
//alert('next');
console.log(e);
}

on render function I added like this
render: function() {
.....

var settings = {
dots: false,
infinite: true,
speed: 500,
swipeToSlide: false,
arrows: true,
slidesToShow: 2,
afterChange: this.nextClick,
slidesToScroll: 2
};

return ()
}

And I got on console 2 4 6 8 10 (Because I show 2 slider Item in one time
And you can keep from "e" variable current Slider Item

I hope it's help you

use afterChange method, it allows to get currentSlide index as callback function's parameter

afterChangeHandler(currentSlide) {
        this.props.updateInitialSlide(currentSlide);
}

<Slider {...settings} afterChange={this.afterChangeHandler}>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

laveesingh picture laveesingh  路  3Comments

enriquelopez-atlas picture enriquelopez-atlas  路  3Comments

ramyatrouny picture ramyatrouny  路  3Comments

rohitgoyal7 picture rohitgoyal7  路  3Comments

darkalor picture darkalor  路  4Comments