Created
April 1, 2019 04:11
-
-
Save wickstjo/77796f3051c9dee9db8b38beee12b625 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'; | |
class App extends Component { | |
render() { return ( | |
<AppContainer /> | |
)} | |
} | |
const MainNavigator = createStackNavigator({ | |
Home: { | |
screen: Home, | |
navigationOptions: { | |
header: null, | |
}, | |
params: { | |
// | |
} | |
}, | |
Create: { | |
screen: Create, | |
navigationOptions: { | |
header: null, | |
}, | |
params: { | |
// | |
} | |
}, | |
Profile: { | |
screen: Profile, | |
navigationOptions: { | |
header: null | |
}, | |
params: { | |
// | |
} | |
}, | |
}); | |
const AppContainer = createAppContainer(MainNavigator); | |
export default App; |
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 storage from './funcs/storage'; | |
class Data extends Component { | |
state = { | |
routes: [] | |
} | |
componentWillMount() { | |
storage.routes().then((response) => { | |
this.setState({ | |
routes: JSON.parse(response).routes | |
}) | |
}); | |
} | |
add = (name) => { | |
new Promise((resolve, reject) => { | |
this.setState({ | |
routes: [...this.state.routes, name] | |
}) | |
resolve(); | |
}).then(() => { | |
storage.save(this.state.routes); | |
}); | |
} | |
remove = (id, header) => { | |
new Promise((resolve, reject) => { | |
this.setState({ | |
routes: this.state.routes.filter((value, index) => index !== id) | |
}) | |
resolve(); | |
}).then(() => { | |
storage.save(this.state.routes); | |
}); | |
} | |
} | |
export default Data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment