From c3269456d543040d540496dc75daf7d78418a0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diogo=20Silv=C3=A9rio?= Date: Sun, 4 Feb 2018 10:26:31 -0200 Subject: [PATCH] FIX: Correcting redirection Redirecting to Deckdetails after the creation of a new deck. --- components/flashcards/NewDeck.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/flashcards/NewDeck.js b/components/flashcards/NewDeck.js index 1edeaa0..a12ada3 100644 --- a/components/flashcards/NewDeck.js +++ b/components/flashcards/NewDeck.js @@ -48,7 +48,11 @@ 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", @@ -56,14 +60,12 @@ class NewDeck extends Component { { 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(