mirror of
https://github.com/zhigang1992/react-native-card-stack-swiper.git
synced 2026-01-12 17:42:18 +08:00
updating componentwillreceiveprops so that it is flexible for a usecase where youre updating the props passed down to a child state (i.e. you favorited a card and added to parent state and you're passing down that state to child as a prop) after an action and you dont want the cards to restart
This commit is contained in:
@@ -136,9 +136,13 @@ export default class CardStack extends Component {
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
this.setState({
|
||||
if (nextProps.children !== this.props.children) {
|
||||
this.setState({
|
||||
cards: nextProps.children,
|
||||
cardA: nextProps.children[0],
|
||||
cardB: nextProps.children[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_resetCard(){
|
||||
|
||||
Reference in New Issue
Block a user