Created
January 26, 2019 00:01
-
-
Save scottdomes/6c6d9b1038f74c1fb3a32b2f2a0f06e9 to your computer and use it in GitHub Desktop.
This file contains 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 { QueryRenderer } from 'react-relay'; | |
import environment from './environment'; | |
import { GET_CONTACTS } from './query'; | |
const QueryComponent = ({ children }) => { | |
return ( | |
<QueryRenderer | |
environment={environment} | |
query={GET_CONTACTS} | |
render={({ error, props }) => { | |
if (error) { | |
return <div>Error!</div>; | |
} | |
if (!props) { | |
return <div>Loading...</div>; | |
} | |
return children(props); | |
}} | |
/> | |
); | |
}; | |
export default QueryComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment