diff options
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/Cart.js | 10 | ||||
| -rw-r--r-- | frontend/components/CreateItem.js | 8 | ||||
| -rw-r--r-- | frontend/components/Items.js | 9 | ||||
| -rw-r--r-- | frontend/components/Pagination.js | 2 | ||||
| -rw-r--r-- | frontend/components/TakeMyMoney.js | 2 |
5 files changed, 12 insertions, 19 deletions
diff --git a/frontend/components/Cart.js b/frontend/components/Cart.js index dbc3e9e..5d68102 100644 --- a/frontend/components/Cart.js +++ b/frontend/components/Cart.js @@ -13,9 +13,13 @@ import CloseButton from './styles/CloseButton'; import SickButton from './styles/SickButton'; const Composed = adopt({ - toggleCart: <Mutation mutation={TOGGLE_CART_MUTATION} />, - localState: <Query query={LOCAL_STATE_QUERY} />, - currentUser: <Query query={CURRENT_USER_QUERY} data-test="cart" />, + toggleCart: <Mutation mutation={TOGGLE_CART_MUTATION}>{() => {}}</Mutation>, + localState: <Query query={LOCAL_STATE_QUERY}>{() => {}}</Query>, + currentUser: ( + <Query query={CURRENT_USER_QUERY} data-test="cart"> + {() => {}} + </Query> + ), }); const Cart = () => ( diff --git a/frontend/components/CreateItem.js b/frontend/components/CreateItem.js index b40932c..0e26330 100644 --- a/frontend/components/CreateItem.js +++ b/frontend/components/CreateItem.js @@ -41,15 +41,9 @@ class CreateItem extends Component { }); }; - // TODO: Problem here - if I refetch page 1, page 2 to infinity are still out of date. I need to refetch all the pages somehow? Or use @connection render() { return ( - <Mutation - mutation={CREATE_ITEM_MUTATION} - variables={this.state} - // TODO - update all items - // refetchQueries={[{ query: ALL_ITEMS_QUERY }]} - > + <Mutation mutation={CREATE_ITEM_MUTATION} variables={this.state}> {(createItem, { loading, error }) => ( <Form data-test diff --git a/frontend/components/Items.js b/frontend/components/Items.js index 9489f5d..2eacd22 100644 --- a/frontend/components/Items.js +++ b/frontend/components/Items.js @@ -24,14 +24,7 @@ class ItemList extends React.Component { static propTypes = { page: PropTypes.number.isRequired, }; - static getDerivedStateFromProps(nextProps, state) { - return { refetch: state.page !== nextProps.page }; - } - state = { - refetch: false, - }; render() { - const fetchPolicy = this.state.refetch ? 'network-only' : 'cache-first'; return ( <Center key={this.props.page}> <Pagination page={this.props.page} /> @@ -41,7 +34,7 @@ class ItemList extends React.Component { skip: this.props.page * perPage - perPage, first: perPage, }} - fetchPolicy={fetchPolicy} + // fetchPolicy="network-only" > {({ data, error, loading }) => { if (loading) { diff --git a/frontend/components/Pagination.js b/frontend/components/Pagination.js index 1432746..cb43a10 100644 --- a/frontend/components/Pagination.js +++ b/frontend/components/Pagination.js @@ -41,6 +41,7 @@ const Pagination = props => ( return ( <PaginationStyles data-test="pagination"> <Link + prefetch href={{ pathname: 'items', query: { page: page - 1 }, @@ -57,6 +58,7 @@ const Pagination = props => ( <strong>{aggregate.count}</strong> Items Total </p> <Link + prefetch href={{ pathname: 'items', query: { page: page + 1 }, diff --git a/frontend/components/TakeMyMoney.js b/frontend/components/TakeMyMoney.js index cadcabb..3ecacb8 100644 --- a/frontend/components/TakeMyMoney.js +++ b/frontend/components/TakeMyMoney.js @@ -62,7 +62,7 @@ class TakeMyMoney extends Component { } TakeMyMoney.propTypes = { - children: PropTypes.any.isRequired, + children: PropTypes.any, }; export default TakeMyMoney; |
