Skip to content

Commit

Permalink
Add enableURLHandling to navigation container
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvicenti committed Jul 10, 2018
1 parent 805064c commit 316e499
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/createNavigationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ export default function createNavigationContainer(Component) {
}

_handleOpenURL = ({ url }) => {
const parsedUrl = urlToPathAndParams(url, this.props.uriPrefix);
const { enableURLHandling, uriPrefix } = this.props;
if (enableURLHandling === false) {
return;
}
const parsedUrl = urlToPathAndParams(url, uriPrefix);
if (parsedUrl) {
const { path, params } = parsedUrl;
const action = Component.router.getActionForPathAndParams(path, params);
Expand Down Expand Up @@ -199,11 +203,14 @@ export default function createNavigationContainer(Component) {
Linking.addEventListener('url', this._handleOpenURL);

// Pull out anything that can impact state
const { persistenceKey, uriPrefix } = this.props;
const startupStateJSON =
persistenceKey && (await AsyncStorage.getItem(persistenceKey));
const url = await Linking.getInitialURL();
const parsedUrl = url && urlToPathAndParams(url, uriPrefix);
const { persistenceKey, uriPrefix, enableURLHandling } = this.props;
let parsedUrl = null;
if (enableURLHandling !== false) {
const startupStateJSON =
persistenceKey && (await AsyncStorage.getItem(persistenceKey));
const url = await Linking.getInitialURL();
parsedUrl = url && urlToPathAndParams(url, uriPrefix);
}

// Initialize state. This must be done *after* any async code
// so we don't end up with a different value for this.state.nav
Expand Down

0 comments on commit 316e499

Please sign in to comment.