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

When merging cards/adding new cards. Current Card Index is Reset to 0 #115

Open
ruskid opened this issue Nov 23, 2017 · 1 comment
Open

Comments

@ruskid
Copy link

ruskid commented Nov 23, 2017

I want to dynamically add cards. when merging like in the example:

this.setState({
          cards: this.state.cards.concat(cards2),
          outOfCards: true
})

if (nextProps.cards !== this.props.cards) {

      if (this.cardAnimation) {
        this.cardAnimation.stop();
        this.cardAnimation = null;
      }

      currentIndex[this.guid] = 0; //Reset to first?
      this.setState({
        cards: [].concat(nextProps.cards),
        card: nextProps.cards[0]
      });
    }

After concat I get shown the first card of cards1 array. How to preserve the current card and aggregate cards?

@kay-es
Copy link

kay-es commented Nov 24, 2017

the lib concats the new cards itself. this should be working:

          cards: cards2,
          outOfCards: true
})

if (nextProps.cards !== this.props.cards) {

      if (this.cardAnimation) {
        this.cardAnimation.stop();
        this.cardAnimation = null;
      }

      currentIndex[this.guid] = 0; //Reset to first?
      this.setState({
        cards: nextProps.cards,
        card: nextProps.cards[0]
      });
    }`

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