Created
September 7, 2018 23:43
-
-
Save linux08/f242d3e80445486b1bf4ec92415c6233 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 from 'react'; | |
| import { | |
| AsyncStorage, | |
| Button, | |
| StatusBar, | |
| StyleSheet, | |
| View, | |
| Text, | |
| } from 'react-native'; | |
| import { MyContext } from '../Provider'; | |
| export default class OtherScreen extends React.Component { | |
| static navigationOptions = { | |
| title: 'Lots of features here', | |
| }; | |
| render() { | |
| return ( | |
| <View style={styles.container}> | |
| <MyContext.Consumer> | |
| {context => (( | |
| <View> | |
| <Button title="I'm done, sign me out" onPress={() => this._signOutAsyn(removeToken)} /> | |
| <Text> Here is your token {context.token} </Text> | |
| <StatusBar barStyle="default" /> | |
| </View> | |
| ))} | |
| </MyContext.Consumer> | |
| </View> | |
| ); | |
| } | |
| _signOutAsync = async (removeToken) => { | |
| removeToken() | |
| .then(() => { | |
| this.props.navigation.navigate('Auth'); | |
| }) | |
| .catch(error => { | |
| this.setState({ error }) | |
| }) | |
| }; | |
| } | |
| const styles = StyleSheet.create({ | |
| container: { | |
| flex: 1, | |
| backgroundColor: '#fff', | |
| alignItems: 'center', | |
| justifyContent: 'center', | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment