From d57fb6e6e0e2fc8704233d080757dad018116c73 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Sun, 25 Mar 2018 19:04:15 -0700 Subject: [PATCH] Fix refactoring errors --- .../src/routers/getNavigationActionCreators.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/react-navigation/src/routers/getNavigationActionCreators.js b/packages/react-navigation/src/routers/getNavigationActionCreators.js index 2f67defa..1eec7ac8 100644 --- a/packages/react-navigation/src/routers/getNavigationActionCreators.js +++ b/packages/react-navigation/src/routers/getNavigationActionCreators.js @@ -1,15 +1,13 @@ import NavigationActions from '../NavigationActions'; +import invariant from '../utils/invariant'; const getNavigationActionCreators = route => { return { goBack: key => { let actualizedKey = key; - if (key === undefined && navigation.state.key) { - invariant( - typeof navigation.state.key === 'string', - 'key should be a string' - ); - actualizedKey = navigation.state.key; + if (key === undefined && route.key) { + invariant(typeof route.key === 'string', 'key should be a string'); + actualizedKey = route.key; } return NavigationActions.back({ key: actualizedKey }); }, @@ -37,11 +35,10 @@ const getNavigationActionCreators = route => { }, setParams: params => { invariant( - navigation.state.key && typeof navigation.state.key === 'string', + route.key && typeof route.key === 'string', 'setParams cannot be called by root navigator' ); - const key = navigation.state.key; - return NavigationActions.setParams({ params, key }); + return NavigationActions.setParams({ params, key: route.key }); }, }; };