alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can a card be aware that it is at the top?

wmonecke opened this issue · comments

I have seen a similar issue here but please bear with me!

My renderCards method is rendering a React.Component that I called Timer. Basically when a card is at the top a countdown timer should start. However, I am trying to start to Timer by listening to changes in the Timer components componentDidUpdate:

componentDidUpdate(prevProps, prevState) {    
    const { activeCardIndex, assignedCardIndex } = this.props

    if (activeCardIndex === assignedCardIndex) {
      console.log('this card is at the top', assignedCardIndex)
    }
  }

However, componentDidUpdate in the Timer component is ONLY called when I swipe through the cards. Any other props passed from the parent won't trigger the componentDidMount(). Any ideas why this is happening?