Skip to content

Instantly share code, notes, and snippets.

@arminyahya
Created November 1, 2019 07:24
Show Gist options
  • Save arminyahya/cfdfbc0d901842de669d093f0a50274c to your computer and use it in GitHub Desktop.
Save arminyahya/cfdfbc0d901842de669d093f0a50274c to your computer and use it in GitHub Desktop.
import React from 'react';
import { Query } from 'react-apollo';
import ScreenFocusHook from './screenFocusHook';
const ProductQuery = (props) => {
const navigation = props.navigation;
const getProductsQuery = /* your grahql query here */
const [setCallBack] = ScreenFocusHook(navigation);
return (<Query query={getProductsQuery} notifyOnNetworkStatusChange>
{
(args) => {
const { loading, data, error, refetch } = args;
setCallBack(refetch);
if (error) {
return '';
}
if (data && data.product) {
return <ProductDetail product={data.product}/>;
} else {
return 'loading'
}
}
}
</Query>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment