moschan / react-native-flip-card

The card component which has a motion of flip for React Native(iOS/Android)
MIT License
387 stars 112 forks source link

Flips on setState and won't retain position #84

Closed rohitpaniker closed 4 years ago

rohitpaniker commented 4 years ago

I have the below code:

<FlipCard flip={false} friction={20} perspective={1000} flipHorizontal={false} flipVertical={true} clickable={true}

<ComponentTwo handleOnPress={() => handleCT()}/>

handleCT = (v) => this.setState({ value: v })

So when I click a button inside and do a setState({ }); the card flips back to original position (flips back and shows content of ) rather than retaining current positions.

Please help me solve this bug

rohitpaniker commented 4 years ago

I have resolved this bug.

Go to: /node_modules/react-native-flip-card/lib/FlipCard.js

MAKE CHANGES FROM:

componentWillReceiveProps (nextProps) { if (this.state.isFlipped !== nextProps.flip) { this._toggleCard() } }

TO:

componentWillReceiveProps (nextProps) { // if (this.state.isFlipped !== nextProps.flip) { // this._toggleCard() // } }