0

At the moment I have a number of the same component that is rendered from a map like so:

{this.state.Tweets.map(t => <Tweet key={t.title} title={t.title} desc={t.desc} />)}

So what I've done is wrapped the entire map object with a transition as such:

<TransitionGroup> {this.state.Tweets.map(t => <Tweet key={t.title} title={t.title} desc={t.desc} />)} </TransitionGroup>

this.state.tweets is updated with the following:

filterTweets() {
  const t = this.state.tweets;
  const filteredTweets = _.filter(t, tweet => tweet.time.end > this.state.time);
  this.setState({ tweets: filteredTweets });
}

However when this.state.Tweets is updated for whatever reason the number of items within the <TransitionGroup> does not update. I can get componentWillEnter lifecycle hook to fire but I can't get anything else to update. Any ideas?

I've tried adding this.state.Tweets as a prop to <TransitionGroup> but that didn't seem to work at all.

ajames
  • 113
  • 4

1 Answers1

0

Actually I had missed a crucial role of the TransitionGroup:

Note that you must call the supplied callbacks after your animation ends, otherwise your component will enter but not leave, or leave but not enter.

ajames
  • 113
  • 4