Skip to content

Instantly share code, notes, and snippets.

@scottdomes
Created January 26, 2019 00:01
Show Gist options
  • Save scottdomes/6c6d9b1038f74c1fb3a32b2f2a0f06e9 to your computer and use it in GitHub Desktop.
Save scottdomes/6c6d9b1038f74c1fb3a32b2f2a0f06e9 to your computer and use it in GitHub Desktop.
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