Skip to content

Instantly share code, notes, and snippets.

@ghankerson
Created May 30, 2019 19:58
Show Gist options
  • Select an option

  • Save ghankerson/d72173fbb2e1775096dc1d2aae6f45d3 to your computer and use it in GitHub Desktop.

Select an option

Save ghankerson/d72173fbb2e1775096dc1d2aae6f45d3 to your computer and use it in GitHub Desktop.
import React, { useContext } from 'react';
import Episodes from './Episodes';
import { episodesQuery } from './EpisodesQuery';
import { Query } from "react-apollo";
import SiteConfigContext from '../../context/SiteConfigContext';
import { Loading } from 'apm-titan';
import PropTypes from 'prop-types';
const EpisodesWithData = (props) => {
const context = useContext(SiteConfigContext);
const pageNum = props.id ? props.id : 1;
const GET_EPISODES = episodesQuery(context.slug, pageNum);
return <Query query={GET_EPISODES}>
{( { loading, error, data } ) => {
if(loading) {
return <Loading />;
}
if(error) {
return <div>Error</div>;
}
return <Episodes data={data} />
}}
</Query>
};
EpisodesWithData.propTypes = {
id: PropTypes.string
};
export default EpisodesWithData;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment