Created
May 30, 2019 19:58
-
-
Save ghankerson/d72173fbb2e1775096dc1d2aae6f45d3 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, { 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