Skip to content

Instantly share code, notes, and snippets.

@phpsmarter
Created March 18, 2018 04:50
Show Gist options
  • Save phpsmarter/158bac90a80044f34cdf8cdf1eb08960 to your computer and use it in GitHub Desktop.
Save phpsmarter/158bac90a80044f34cdf8cdf1eb08960 to your computer and use it in GitHub Desktop.
import { ChildProps } from "react-apollo";
const withCharacter = graphql<Response, InputProps>(HERO_QUERY, {
options: ({ episode }) => ({
variables: { episode }
})
});
class Character extends React.Component<ChildProps<InputProps, Response>, {}> {
render(){
const { loading, hero, error } = this.props.data;
if (loading) return <div>Loading</div>;
if (error) return <h1>ERROR</h1>;
return ...// actual component with data;
}
}
export default withCharacter(Character);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment