blob: 8581009179c200d0244b463ba1d2071841b61b32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import React, { Component } from 'react';
import { graphql, compose } from 'react-apollo';
import { CURRENT_USER_QUERY } from '../queries';
class Signout extends Component {
signout = () => {
console.log('Signing Out');
localStorage.removeItem('token');
this.props.currentUser.refetch();
};
render() {
const { me, loading, error } = this.props.currentUser;
if (!me || loading || error) return null;
return <button onClick={this.signout}>Sign Out</button>;
}
}
const userEnhancer = graphql(CURRENT_USER_QUERY, { name: 'currentUser' });
export default compose(userEnhancer)(Signout);
|