import { Component } from 'react' import { graphql, compose } from 'react-apollo' import { CURRENT_USER_QUERY } from '../queries'; import Cart from './Cart'; import Login from './LoginAuth0'; import Search from './Search'; class Header extends Component { componentDidMount() { // This fetches the new data, but doesn't populate the user via props // this.props.currentUserQuery.refetch(); // This fetches the new data, and populates the user via props setTimeout(this.props.currentUserQuery.refetch, 1); } render() { const user = this.props.currentUserQuery.user || {}; const { email = '' } = user; return (

Signed in as {email}

) } } const userEnhancer = graphql(CURRENT_USER_QUERY, { name: 'currentUserQuery' }); export default compose(userEnhancer)(Header)