Skip to content

Instantly share code, notes, and snippets.

@linux08
Created September 7, 2018 23:43
Show Gist options
  • Select an option

  • Save linux08/f242d3e80445486b1bf4ec92415c6233 to your computer and use it in GitHub Desktop.

Select an option

Save linux08/f242d3e80445486b1bf4ec92415c6233 to your computer and use it in GitHub Desktop.
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