diff options
Diffstat (limited to 'frontend/components/Signout.js')
| -rw-r--r-- | frontend/components/Signout.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/frontend/components/Signout.js b/frontend/components/Signout.js new file mode 100644 index 0000000..97eef40 --- /dev/null +++ b/frontend/components/Signout.js @@ -0,0 +1,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 of {me.id}👋 🏻</button>; + } +} + +const userEnhancer = graphql(CURRENT_USER_QUERY, { name: 'currentUser' }); +export default compose(userEnhancer)(Signout); |
