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

[BUG] Warning: Cannot update a component (ForwardRef(BaseNavigationContainer)) while rendering a different component (SwipeCards). #26

Open
hristowwe opened this issue Jan 19, 2022 · 1 comment

Comments

@hristowwe
Copy link

I tried ti ran following code

        <SwipeCards
          ref={sheetRef}
          cards={cards}
          renderCard={(cardData) => <Card data={cardData.text} />}
          keyExtractor={(cardData) => String(cardData.text)}
          renderNoMoreCards={() => {
            navigation.navigate("CardsPage");
          }}
          actions={{
            nope: { onAction: handleNope, text: "Не" },
            yup: { onAction: handleYup, text: "Да" },
          }}
          hasMaybeAction={false}
          // If you want a stack of cards instead of one-per-one view, activate stack mode
          // stackDepth={3}
        />

But i got error
Warning: Cannot update a component (ForwardRef(BaseNavigationContainer)) while rendering a different component (SwipeCards). To locate the bad setState() call inside SwipeCards, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
It is happened when i use navigation.navigate in renderNoMoreCards. How can i fix that? Or i cant use navigate like that?

@eyalabs
Copy link

eyalabs commented May 20, 2022

renderNoMoreCards expects a react view to render whenever the cards are empty.
Currently there is no event handler for empty cards, but you can implement a custom component for renderNoMoreCards and put the navigate side effect on useEffect.
This could work.

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