From a6af043686e4375d7944e91cae3d5b63c59edab0 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 22 Mar 2018 16:29:31 -0400 Subject: Migrate to render props --- frontend/components/Nav.js | 87 ++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 46 deletions(-) (limited to 'frontend/components/Nav.js') diff --git a/frontend/components/Nav.js b/frontend/components/Nav.js index 3d7f0f6..b898fd5 100644 --- a/frontend/components/Nav.js +++ b/frontend/components/Nav.js @@ -1,9 +1,8 @@ import React, { Fragment } from 'react'; import Link from 'next/link'; import styled from 'styled-components'; -import { compose } from 'react-apollo'; -import PropTypes from 'prop-types'; -import { userEnhancer } from '../enhancers/enhancers'; +import { Query } from 'react-apollo'; +import { CURRENT_USER_QUERY } from '../queries/index'; import CartCount from './CartCount'; import Signout from './Signout'; import { UIContext } from './UIContext'; @@ -59,55 +58,51 @@ const StyledUl = styled.ul` `; class Nav extends React.Component { - static propTypes = { - currentUser: PropTypes.object.isRequired, - }; - componentDidMount() { - this.props.currentUser.refetch(); - } render() { - const { currentUser } = this.props; return ( - - - Shop - - - Sell - - - {!currentUser.me && ( - - Sign In - - )} - - {currentUser.me && ( - - - Orders + + {({ data: { me } }) => ( + + + Shop - - My Account + + Sell - - - {context => ( - - )} - - + + {!me && ( + + Sign In + + )} + + {me && ( + + + Orders + + + My Account + + + + {context => ( + + )} + + + )} + )} - + ); } } -export default compose(userEnhancer)(Nav); -export { Nav }; +export default Nav; -- cgit v1.3