Last active
June 4, 2018 08:16
-
-
Save clarencenpy/0767a055c656b3bc1613ee93b4e26198 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'; | |
const MovieSearchResults = ({ keyword }) => ( | |
<Query query={SEARCH_MOVIES} variables={{ keyword }}> | |
{(data, loading, error) => { | |
if (loading) return <LoadingIndicator />; | |
// if networkError is present, we can be sure that no data | |
// was returned. We can simply display an error component. | |
if (error && error.networkError) return <ErrorDisplay />; | |
return ( | |
<div> | |
{data.movies ? | |
<MovieList movies={data.movies} /> | |
: <ErrorDisplay /> | |
} | |
{data.recommendedForYou ? | |
<RecommendedMovieList movies={data.recommendedForYou} /> | |
: <ErrorDisplay /> | |
} | |
</div> | |
); | |
}} | |
</Query> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment