Skip to content

Commit

Permalink
- Fix GraphQL validation errors
Browse files Browse the repository at this point in the history
- Memoize click event for enabling form
  • Loading branch information
tjwiebell committed Feb 6, 2020
1 parent f9a3c8e commit 2746e6c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useLazyQuery } from '@apollo/react-hooks';

import { useCartContext } from '../../../../context/cart';
Expand All @@ -14,7 +14,7 @@ export const useShippingMethods = props => {
);

const [isShowingForm, setIsShowingForm] = useState(false);
const showForm = () => setIsShowingForm(true);
const showForm = useCallback(() => setIsShowingForm(true), []);

useEffect(() => {
if (cartId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ShippingForm.propTypes = {
export const GET_COUNTRIES_QUERY = gql`
query GetCountries {
countries {
id
full_name_english
two_letter_abbreviation
}
Expand Down Expand Up @@ -146,6 +147,7 @@ export const SET_SHIPPING_MUTATION = gql`
}
) {
cart {
id
...ShippingMethodsFragment
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default ShippingMethods;
export const GET_SHIPPING_METHODS = gql`
query GetShippingMethods($cartId: String!) {
cart(cart_id: $cartId) {
id
...ShippingMethodsFragment
}
}
Expand Down

0 comments on commit 2746e6c

Please sign in to comment.