From 4daef52d648db9953e68fa99495db047833a4ad9 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Tue, 15 May 2018 11:01:32 -0400 Subject: move user check to _app --- frontend/components/Page.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'frontend/components') diff --git a/frontend/components/Page.js b/frontend/components/Page.js index 179c0ab..594e90d 100644 --- a/frontend/components/Page.js +++ b/frontend/components/Page.js @@ -3,8 +3,7 @@ import styled, { ThemeProvider, injectGlobal } from 'styled-components'; import PropTypes from 'prop-types'; import Header from './Header'; import Meta from './Meta'; -import { client } from '../lib/withData'; -import { CURRENT_USER_QUERY } from '../queries/queries'; +import { ApolloConsumer } from 'react-apollo'; const theme = { red: '#FF0000', @@ -53,24 +52,19 @@ class Page extends React.Component { static propTypes = { children: PropTypes.node.isRequired, }; - componentDidMount() { - // The first time we load in the client, we need to refetch the current user data - // TODO use ApolloContext API here instead - // TODO can we just use _app for this? - if (typeof window !== 'undefined' && !window.__CLIENTLOADED__) { - client.query({ query: CURRENT_USER_QUERY, fetchPolicy: 'network-only' }); - window.__CLIENTLOADED__ = true; - } - } render() { return ( - - - -
- {this.props.children} - - + + {client => ( + + + +
+ {this.props.children} + + + )} + ); } } -- cgit v1.3