From c641bee11bbbfce7244f147e213de7ff51545d78 Mon Sep 17 00:00:00 2001 From: Eric Vicenti Date: Wed, 2 May 2018 09:17:00 -0700 Subject: [PATCH] Fix initial action dispatch for nonPersisted apps (#4104) --- src/createNavigationContainer.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/createNavigationContainer.js b/src/createNavigationContainer.js index a13fc36b..9d1944bb 100644 --- a/src/createNavigationContainer.js +++ b/src/createNavigationContainer.js @@ -252,12 +252,7 @@ export default function createNavigationContainer(Component) { } } - if (startupState === this.state.nav) { - return; - } - - this.setState({ nav: startupState }, () => { - _reactNavigationIsHydratingState = false; + const dispatchActions = () => this._actionEventSubscribers.forEach(subscriber => subscriber({ type: 'action', @@ -266,6 +261,15 @@ export default function createNavigationContainer(Component) { lastState: null, }) ); + + if (startupState === this.state.nav) { + dispatchActions(); + return; + } + + this.setState({ nav: startupState }, () => { + _reactNavigationIsHydratingState = false; + dispatchActions(); }); }