Skip to content

Commit

Permalink
FIX: Correcting redirection
Browse files Browse the repository at this point in the history
Redirecting to Deckdetails after the creation of a new deck.
  • Loading branch information
diogosilverio committed Feb 4, 2018
1 parent 5a1bfa8 commit c326945
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions components/flashcards/NewDeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,24 @@ class NewDeck extends Component {

async createNewDeck() {
try {
if (this.state.deck.name.trim() === '') {
const { deck } = this.state;
const { navigation } = this.props;
const rootNavigation = this.props.screenProps.rootNavigation;

if (deck.name.trim() === '') {
Alert.alert(
'Required',
"Deck's name is required",
[{ text: 'Ok', onPress: () => { } }],
{ cancelable: false });
return;
}

persistDeck(this.state.deck);
this.props.dispatch(newDeck(this.state.deck));

const routeName = "Index";
const navigation = NavigationActions.navigate({ routeName });
persistDeck(deck);
this.props.dispatch(newDeck(deck));

this.props.navigation.dispatch(navigation);
navigation.goBack();
rootNavigation.navigate('DeckDetails', { deckKey: deck.name })

} catch (e) {
Alert.alert(
Expand Down

0 comments on commit c326945

Please sign in to comment.