From 19c9683e2126c68cb9d231293162c756d69c51fb Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 8 Feb 2018 10:41:16 -0500 Subject: WIP --- frontend/components/Signout.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 frontend/components/Signout.js (limited to 'frontend/components/Signout.js') 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 ; + } +} + +const userEnhancer = graphql(CURRENT_USER_QUERY, { name: 'currentUser' }); +export default compose(userEnhancer)(Signout); -- cgit v1.3