Created
November 1, 2019 07:24
-
-
Save arminyahya/cfdfbc0d901842de669d093f0a50274c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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