Created
March 31, 2019 07:35
-
-
Save wickstjo/673610ccde72c5d10cd794303a4509a1 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 { createStackNavigator, createAppContainer } from 'react-navigation'; | |
import Home from './pages/home/home'; | |
import Profile from './pages/profile/profile'; | |
import Create from './pages/create/create'; | |
import storage from './funcs/storage'; | |
class App extends Component { | |
state = { | |
routes: storage.get_profiles() | |
} | |
add = (name) => { | |
this.setState({ | |
routes: [...this.state.routes, name] | |
}) | |
} | |
remove = (id, header) => { | |
this.setState({ | |
routes: this.state.routes.filter((value, index) => index !== id) | |
}) | |
} | |
render() { | |
const MainNavigator = createStackNavigator({ | |
Home: { | |
screen: Home, | |
navigationOptions: { | |
header: null, | |
}, | |
params: { | |
routes: this.state.routes, | |
remove: this.remove | |
} | |
}, | |
Create: { | |
screen: Create, | |
navigationOptions: { | |
header: null, | |
}, | |
params: { | |
add: this.add | |
} | |
}, | |
Profile: { | |
screen: Profile, | |
navigationOptions: { | |
header: null | |
} | |
}, | |
}); | |
const AppContainer = createAppContainer(MainNavigator); | |
return ( <AppContainer /> ) | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment