Skip to content

Instantly share code, notes, and snippets.

@lrlineroa
Created July 4, 2019 01:50
Show Gist options
  • Save lrlineroa/615fcd1cae20b7271c0edc4eb1a68303 to your computer and use it in GitHub Desktop.
Save lrlineroa/615fcd1cae20b7271c0edc4eb1a68303 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Card, CardItem, Button } from 'native-base';
class Training extends Component {
//nuevo
static navigationOptions = ({ navigation }) => {
return {
title: 'Repaso'
}
};
//nuevo
constructor(props) {
super(props);
this.state = {
currentIndex: 0,//<--nuevo
cards: props.navigation.getParam('cards')//<--nuevo
}
}
render() {
console.log('cards tra : ' + JSON.stringify(this.state.cards))//<--para testear
return (<View>
<Card>
<CardItem>
<Text style={{ fontSize: 30 }}>
{this.state.cards[this.state.currentIndex].value}
</Text>
</CardItem>
</Card>
<Button
onPress={() => this.setState({
currentIndex: this.state.currentIndex + 1
})}
disabled={
this.state.currentIndex == this.state.cards.length - 1
}
>
<Text>Siguiente</Text>
</Button>
</View>);
}
}
export default Training;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment