diff options
| author | Wes Bos <wesbos@gmail.com> | 2017-08-25 09:33:53 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2017-08-25 09:33:53 -0400 |
| commit | 7af74ff8988961c988f03c95961b70c2918521ae (patch) | |
| tree | d73cd0dd94751b76595b7febcae4162811c2040b /components/Header.js | |
| parent | 416c2cbae0e69b724876d232bf813eefd7550174 (diff) | |
yay
Diffstat (limited to 'components/Header.js')
| -rw-r--r-- | components/Header.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/components/Header.js b/components/Header.js new file mode 100644 index 0000000..52aeef9 --- /dev/null +++ b/components/Header.js @@ -0,0 +1,28 @@ +import { Component } from 'react' +import { graphql, compose } from 'react-apollo' +import { CURRENT_USER_QUERY } from '../queries'; + +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() { + console.log(this.props.currentUserQuery.user); + const user = this.props.currentUserQuery.user || {}; + const { email = '' } = user; + + return ( + <div> + <p>{email} I'm the header!</p> + </div> + ) + } +} + +const userEnhancer = graphql(CURRENT_USER_QUERY, { name: 'currentUserQuery' }); +export default compose(userEnhancer)(Header) |
