From 128b698a0340fd402c4c7796bca9769f2adb2c59 Mon Sep 17 00:00:00 2001 From: Andrei Coman Date: Tue, 6 Sep 2016 06:38:53 -0700 Subject: [PATCH] UIExplorer fixes Summary: Currently, when reloading uiexplorer, it does not go back to the last visited component. This fixes it, by only storing the state (which contains the last visited component), after it has been set. Reviewed By: bestander Differential Revision: D3821288 fbshipit-source-id: 5b9ba10765ce402c20016519a3b7f6b5211cc623 --- Examples/UIExplorer/js/UIExplorerApp.android.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples/UIExplorer/js/UIExplorerApp.android.js b/Examples/UIExplorer/js/UIExplorerApp.android.js index d2331402aec5e1..7d1b9aecdc8526 100644 --- a/Examples/UIExplorer/js/UIExplorerApp.android.js +++ b/Examples/UIExplorer/js/UIExplorerApp.android.js @@ -50,8 +50,8 @@ type Props = { exampleFromAppetizeParams: string, }; -type State = { - initialExampleUri: ?string, +type State = UIExplorerNavigationState & { + externalExample: ?string, }; class UIExplorerApp extends React.Component { @@ -185,8 +185,10 @@ class UIExplorerApp extends React.Component { this.drawer && this.drawer.closeDrawer(); const newState = UIExplorerNavigationReducer(this.state, action); if (this.state !== newState) { - this.setState(newState); - AsyncStorage.setItem('UIExplorerAppState', JSON.stringify(this.state)); + this.setState( + newState, + () => AsyncStorage.setItem('UIExplorerAppState', JSON.stringify(this.state)) + ); return true; } return false;