diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-15 11:01:32 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-15 11:01:32 -0400 |
| commit | 4daef52d648db9953e68fa99495db047833a4ad9 (patch) | |
| tree | 88257aa26c3ca9bcd3188f5f0cb680befc64fe31 /frontend/components | |
| parent | a87f7f9b49a8de91f8c65476c9badccc2c4c69c6 (diff) | |
move user check to _app
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/Page.js | 30 |
1 files changed, 12 insertions, 18 deletions
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 ( - <ThemeProvider theme={theme}> - <StyledPage className="main"> - <Meta /> - <Header /> - <Inner>{this.props.children}</Inner> - </StyledPage> - </ThemeProvider> + <ApolloConsumer> + {client => ( + <ThemeProvider theme={theme}> + <StyledPage className="main"> + <Meta /> + <Header /> + <Inner>{this.props.children}</Inner> + </StyledPage> + </ThemeProvider> + )} + </ApolloConsumer> ); } } |
