Created
January 19, 2019 01:44
-
-
Save BrodaNoel/22be8c10f627422ec53d0f688adf7342 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, { Component } from 'react'; | |
import duix from 'duix'; | |
// Pages | |
import Loading from './src/pages/Loading'; | |
import Login from './src/pages/Login'; | |
import Home from './src/pages/Home'; | |
import Contact from './src/pages/Contact'; | |
// ...more dependencies... | |
const DEFAULT_PAGE = 'Loading'; | |
duix.set('currentPage', DEFAULT_PAGE); | |
class App extends Component { | |
state = { | |
currentPage: DEFAULT_PAGE | |
}; | |
componentDidMount() { | |
duix.subscribe('currentPage', this.onCurrentPageChange); | |
} | |
onCurrentPageChange = (currentPage) => { | |
this.setState({ currentPage }); | |
}; | |
render() { | |
return ( | |
<View style={[{ flex: 1 }]}> | |
{ | |
{ | |
Loading: <Loading />, | |
Login: <Login />, | |
Home: <Home />, | |
Contact: <Contact /> | |
}[this.state.currentPage] | |
} | |
</View> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment