Created
March 23, 2018 14:36
-
-
Save Kebabpizza/925531ed9bab37ba6abf48f5de9c812a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { View, Text } from "react-native"; | |
import { | |
StackNavigator, | |
addNavigationHelpers, | |
NavigationActions | |
} from "react-navigation"; | |
import { | |
setJSExceptionHandler, | |
getJSExceptionHandler | |
} from "react-native-exception-handler"; | |
setJSExceptionHandler((error, isFatal) => { | |
alert(error); | |
}, true); | |
class View1 extends React.Component { | |
componentWillMount() { | |
const promise = new Promise(resolve => { | |
setTimeout(() => { | |
console.log("ran promise"); | |
resolve(true); | |
}, 2000); | |
}); | |
promise.then(() => { | |
this.props.navigation.dispatch( | |
NavigationActions.navigate({ | |
routeName: "View2" | |
}) | |
); | |
}); | |
} | |
render() { | |
return ( | |
<View> | |
<Text>View1</Text> | |
</View> | |
); | |
} | |
} | |
class View2 extends React.Component { | |
componentWillMount() { | |
this.shouldCrash(); | |
} | |
render() { | |
return ( | |
<View> | |
<Text>View2</Text> | |
</View> | |
); | |
} | |
} | |
var routes = StackNavigator( | |
{ | |
View1: { | |
screen: View1 | |
}, | |
View2: { | |
screen: View2 | |
} | |
}, | |
{} | |
); | |
const AppNavigator = routes; | |
export default class App extends React.Component { | |
render() { | |
return <AppNavigator />; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment