diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-24 15:24:33 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-24 15:24:33 -0400 |
| commit | 549cfa77c9fec0936c3a8d87a49b69401cbfbd7a (patch) | |
| tree | 18a5044807f3034c1cea67c74987e67c572f17bd /frontend/components/Nav.js | |
| parent | 072eca0e5038a7755ca9b2c94dfe1a0c3f110968 (diff) | |
toggle cart mutesss
Diffstat (limited to 'frontend/components/Nav.js')
| -rw-r--r-- | frontend/components/Nav.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/frontend/components/Nav.js b/frontend/components/Nav.js index 826335f..b483376 100644 --- a/frontend/components/Nav.js +++ b/frontend/components/Nav.js @@ -1,6 +1,7 @@ import React, { Fragment } from 'react'; import Link from 'next/link'; -import { Query, ApolloConsumer } from 'react-apollo'; +import { Query, Mutation } from 'react-apollo'; +import { TOGGLE_CART_MUTATION } from './Cart'; import User from './User'; import CartCount from './CartCount'; import Signout from './Signout'; @@ -35,9 +36,9 @@ class Nav extends React.Component { <a>My Account</a> </Link> <Signout /> - <ApolloConsumer> - {cache => ( - <button onClick={() => cache.writeData({ data: { cartOpen: true } })}> + <Mutation mutation={TOGGLE_CART_MUTATION}> + {toggleCart => ( + <button onClick={toggleCart}> My Cart <CartCount className="cart-count" @@ -45,7 +46,7 @@ class Nav extends React.Component { /> </button> )} - </ApolloConsumer> + </Mutation> </Fragment> )} </NavStyles> |
