Update props fix

Updating the data on the visible card, without restarting the deck
This commit is contained in:
Ludwig Händel
2018-02-28 23:34:29 +01:00
parent f97abff8b6
commit 37d425336d
2 changed files with 5 additions and 5 deletions

View File

@@ -138,10 +138,10 @@ export default class CardStack extends Component {
componentWillReceiveProps(nextProps){
if (nextProps.children !== this.props.children) {
this.setState({
cards: nextProps.children,
cardA: nextProps.children[0],
cardB: nextProps.children[1],
});
cards: nextProps.children,
cardA: nextProps.children[(this.state.topCard=='cardA')? this.state.sindex-2 : this.state.sindex-1],
cardB: nextProps.children[(this.state.topCard=='cardB')? this.state.sindex-2 : this.state.sindex-1]
});
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-card-stack-swiper",
"version": "1.0.47",
"version": "1.0.5",
"description": "Tinder like react-native card stack swiper",
"main": "index.js",
"scripts": {