Skip to content

Instantly share code, notes, and snippets.

@clarencenpy
Last active June 4, 2018 08:16
Show Gist options
  • Save clarencenpy/0767a055c656b3bc1613ee93b4e26198 to your computer and use it in GitHub Desktop.
Save clarencenpy/0767a055c656b3bc1613ee93b4e26198 to your computer and use it in GitHub Desktop.
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