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
This commit is contained in:
Andrei Coman 2016-09-06 06:38:53 -07:00 committed by Facebook Github Bot 6
parent d31756bf01
commit 128b698a03

View File

@ -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;