Created
March 18, 2018 04:50
-
-
Save phpsmarter/158bac90a80044f34cdf8cdf1eb08960 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 { 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