akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.72k stars 2.1k forks source link

How do react-slick always start on the first slide? #1621

Open engmsilva opened 5 years ago

engmsilva commented 5 years ago

My slide points to several end points of an image api, but always when I change the end point direction to the react-slide and it always returns to the previous state, but the beforeChange method returns currentIndex equal to zero. Already tried to use the goTo method to return to the position after loading new data and nothing happens.

What is the best way to solve this?

engmsilva commented 5 years ago

I noticed that disabling the beforeChange method the problem does not occur. What is the relation of this method as the initialslide props?

beforeChange: (old , current) => setStatusCore({...statusCore, oldIndex: old , currentIndex: current}),

engmsilva commented 5 years ago

I changed the method to afterChange and it worked

afterChange: (current) => setStatusCore({...statusCore, currentIndex: current}),