Skip to content

Instantly share code, notes, and snippets.

@biyootiful
Last active October 30, 2017 21:51
Show Gist options
  • Save biyootiful/fe64fa7544e8f1352dbee56e01be2f74 to your computer and use it in GitHub Desktop.
Save biyootiful/fe64fa7544e8f1352dbee56e01be2f74 to your computer and use it in GitHub Desktop.
export default class App extends Component {
constructor() {
super();
this.state = {
currentPage: "start"
};
this.handlePage = this.handlePage.bind(this);
}
handlePage(page) {
this.setState({ currentPage: page });
}
renderScreen() {
const { currentPage } = this.state;
switch (currentPage) {
case "start":
return <StartPage handlePage={this.handlePage} />;
case "main":
return <MainPage handlePage={this.handlePage} />;
default:
return <Text style={styles.text}>Something went wrong</Text>;
}
}
render() {
return (
<View style={styles.container}>
<Image
style={styles.witchBackground}
source={require("./img/witch.jpg")}
>
{this.renderScreen()}
</Image>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment