Skip to content

Instantly share code, notes, and snippets.

@Kebabpizza
Created March 23, 2018 14:36
Show Gist options
  • Save Kebabpizza/925531ed9bab37ba6abf48f5de9c812a to your computer and use it in GitHub Desktop.
Save Kebabpizza/925531ed9bab37ba6abf48f5de9c812a to your computer and use it in GitHub Desktop.
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