react-spring-carousel icon indicating copy to clipboard operation
react-spring-carousel copied to clipboard

getCurrentActiveItem is always the first item

Open cryptiklemur opened this issue 3 years ago • 4 comments
trafficstars

Never seems to change.

cryptiklemur avatar Oct 01 '22 09:10 cryptiklemur

Did you manage to work around this @aequasi ?

nathanbirrell avatar Mar 30 '23 23:03 nathanbirrell

I did not

cryptiklemur avatar Mar 30 '23 23:03 cryptiklemur

@aequasi Hi and sorry for the delay! useSpringCarousel doesn't leverage on react state updates, so in order to use getCurrentActiveItem you need to use it inside the useListenToCustomEvent

Emiliano-Bucci avatar Apr 28 '23 15:04 Emiliano-Bucci

@aequasi Hi and sorry for the delay! useSpringCarousel doesn't leverage on react state updates, so in order to use getCurrentActiveItem you need to use it inside the useListenToCustomEvent

Hi! I'm experiencing a similar problem, even though i use it according to your instruction:

useListenToCustomEvent((event) => {
    if (event.eventName === "onSlideChange") {
      let newIndex = event;
      console.log(util.inspect(newIndex, false, null))
    }
  });

Each time i slide through carousel, I get this kind of console.log:

{ eventName: 'onSlideChange',
 slideActionType: 'next',
 currentItem: { index: -1, id: '' } }

CurrentItem never seems to change

Raiden0456 avatar May 22 '23 19:05 Raiden0456