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

Cannot update a component (`RingComponent`) while rendering a different component (`wrappedCard`)

Open AudouxH opened this issue 2 years ago • 0 comments

Hi everyone,

I develop a pwa and i meet a problem with the prev and next function from carousel, i have this issue when i call them.

Screenshot from 2022-05-31 13 17 57

I declare my carousel like that :

const CarouselRef = useRef<any>({
    next: () => null,
    prev: () => null,
  });

i use prev and next like that :

const snapSelectedMember = () => {
    if (!selectedMember) return;
    const index = ordersMembers.findIndex(member => member.id === selectedMember.id) || 0;
    if(index === -1) return;
if (index < currentIndex) {
      for (let i = index; i <= currentIndex; i++) { CarouselRef.current.prev(); }
    } else {
      for (let i = currentIndex; i <= index; i++) { CarouselRef.current.next(); }
    }
    setCurrentIndex(index);
};

and this is my touch carousel :

        ref={CarouselRef}
        component={CarouselContainer}
        cardCount={ordersMembers?.length}
        renderCard={(index: number, modIndex: any, cursor: number, carouselState: any) => RenderCard({ index, modIndex, cursor, carouselState, item: ordersMembers[modIndex], currentIndex, onIndexChange })}
        defaultCursor={currentIndex}
        onDragStart={() => setDisableDraging(true)}
        onDragEnd={() => setDisableDraging(false)}
        onDragCancel={() => setDisableDraging(false)}
        loop={false}
      />

Do you have any idea where come from my issue ?

AudouxH avatar May 31 '22 15:05 AudouxH