Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

currentIndex how to work with it ? #50

Closed
shrinandhini2801 opened this issue Mar 24, 2017 · 1 comment
Closed

currentIndex how to work with it ? #50

shrinandhini2801 opened this issue Mar 24, 2017 · 1 comment

Comments

@shrinandhini2801
Copy link

I need to get which item is showing or brought to front now . Is it possible through current index? There is no sample provided. Can you help on it ?

@bd-arc
Copy link
Contributor

bd-arc commented Mar 24, 2017

@shrinandhini2801 You need to keep a reference to your carousel's instance like this :

<Carousel
  ref={(carousel) => { this._carousel = carousel; }}
  // other props
/>

Then, whenever needed, you can call the following:

if (this._carousel) {
    alert(this._carousel.currentIndex);
}

If you need to update your state every time a change of slide occurs, make sure to use the onSnapToItem prop instead.

@bd-arc bd-arc closed this as completed Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants