Giter VIP home page Giter VIP logo

Comments (8)

zelgan90 avatar zelgan90 commented on May 18, 2024 3

Has anyone found a solution or effective workaround for this? This component works much better than other swipers, but things like this are almost a deal breaker.

from react-native-deck-swiper.

yonahforst avatar yonahforst commented on May 18, 2024 3

please reopen

from react-native-deck-swiper.

alexbrillant avatar alexbrillant commented on May 18, 2024

@acesetmatch I think 1.3.3 fixed it. closing the issue.

from react-native-deck-swiper.

DFelten avatar DFelten commented on May 18, 2024

This problem is still there with version 1.4.2. I've created a modal which appears when tapping on the card and when opening the modal, the card stack resets to the first card.

onTapCard = (cardIndex) => {
  this.setState({currentCardIndex: cardIndex});
  this.setDetailsVisible(true);
};
<Swiper
  ref={swiper => {
    this.swiper = swiper;
  }}
  cards={this.state.cards}
  renderCard={this.renderCard}
  onTapCard={this.onTapCard}
  cardIndex={this.state.cardIndex}
  horizontalSwipe={this.state.horizontalSwipe}
  verticalSwipe={this.state.verticalSwipe}
  showSecondCard={this.state.showNextCard}
  goBackToPreviousCardOnSwipeBottom={this.state.verticalSwipeBack}
  goBackToPreviousCardOnSwipeRight={this.state.horizontalSwipeBack}
  infinite={this.state.infiniteSwiping}
  backgroundColor={Colors.transparent}
  cardStyle={styles.cardSwiper}
  cardVerticalMargin={10}>
</Swiper>
<Modal
  animationType="slide"
  transparent={false}
  visible={this.state.detailsVisible}
  onRequestClose={() => {
    this.setDetailsVisible(false);
    this.setState({cardIndex: this.state.currentCardIndex}); // workaround with warning
  }}
>

In the moment I need so set the cardIndex manually to the current index, but then there is a warning.

Warning: flattenChildren(...): Encountered two children with the same key, 1. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted รขโ‚ฌโ€ the behavior is unsupported and could change in a future version.

An other problem with this workaround is that the next visible card is now the second card and not the next one.

this.swiper.jumpToCardIndex(currentIndex); when closing the modal is also not working, nothing happens.

from react-native-deck-swiper.

vivianmauer avatar vivianmauer commented on May 18, 2024

I have the same problem, when open modal, cards resets to the first card

@DFelten you can work around this issue?

from react-native-deck-swiper.

unmec avatar unmec commented on May 18, 2024

I guess this issue should be reopened.
I looked into example project in the repo and it throws "Encountered two children with the same key" warning too.

from react-native-deck-swiper.

bispul avatar bispul commented on May 18, 2024

yeah I am getting the following error and it resets the card to first index:

Warning: flattenChildren(...): Encountered two children with the same key, 0. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted โ€” the behavior is unsupported and could change in a future version.

from react-native-deck-swiper.

mrexodia avatar mrexodia commented on May 18, 2024

When setting infinite={true} you need to have at least stackSize elements in your cards, which works around the issue for me.

from react-native-deck-swiper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.