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

Cannot update a component (RingComponent) while rendering a different component (wrappedCard) #46

Open
AudouxH opened this issue May 31, 2022 · 0 comments

Comments

@AudouxH
Copy link

AudouxH commented May 31, 2022

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 ?

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

1 participant