swaplet / react-native-swipe-cards-deck

A swipping cards deck (similar to Tinder)
MIT License
46 stars 19 forks source link

onClickHandler not working #21

Closed NikLucoz closed 3 years ago

NikLucoz commented 3 years ago

Hi, when i try to use onCLickHandler on the swipe card i don't recive the default alert. This is the code i used:

render() {
    return (
      <SwipeCards
        cards={this.state.cards}
        renderCard={(cardData) => <Card {...cardData} />}
        keyExtractor={(cardData) => String(cardData.text)}
        renderNoMoreCards={() => <NoMoreCards />}
        handleYup={this.handleYup}
        handleNope={this.handleNope}
        dragY={false}
        onClickHandler={alert("click")}
      />
    )
  }
eyalabs commented 3 years ago

You are not doing it right, you should give the handler a function onClickHandler={()=>alert("click")}

BTW: I recommend you handling on-click within your component (when rendering a card, render it with on-click inside it so you'll have full control over what is clicking.