From 708530a9059876daa76c06b6bcc0b81b856432fd Mon Sep 17 00:00:00 2001 From: Hedger Wang Date: Fri, 27 May 2016 15:30:59 -0700 Subject: [PATCH] Handle old navigation state safely. Reviewed By: mkonicek Differential Revision: D3359593 fbshipit-source-id: ca6dbcf14a31491bc6a3730243f358f21971e9f3 --- Examples/UIExplorer/UIExplorerApp.ios.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/UIExplorer/UIExplorerApp.ios.js b/Examples/UIExplorer/UIExplorerApp.ios.js index 1e05c795cba..f87cfff9fe9 100644 --- a/Examples/UIExplorer/UIExplorerApp.ios.js +++ b/Examples/UIExplorer/UIExplorerApp.ios.js @@ -60,6 +60,8 @@ type State = UIExplorerNavigationState & { externalExample?: string, }; +const APP_STATE_KEY = 'UIExplorerAppState.v1'; + class UIExplorerApp extends React.Component { _renderOverlay: Function; _renderScene: Function; @@ -81,7 +83,7 @@ class UIExplorerApp extends React.Component { componentDidMount() { Linking.getInitialURL().then((url) => { - AsyncStorage.getItem('UIExplorerAppState', (err, storedString) => { + AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => { const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams); const urlAction = URIActionMap(url); const launchAction = exampleAction || urlAction; @@ -111,7 +113,7 @@ class UIExplorerApp extends React.Component { const newState = UIExplorerNavigationReducer(this.state, action); if (this.state !== newState) { this.setState(newState); - AsyncStorage.setItem('UIExplorerAppState', JSON.stringify(this.state)); + AsyncStorage.setItem(APP_STATE_KEY, JSON.stringify(this.state)); } }