Created
June 2, 2017 10:18
-
-
Save ncrmro/99778af3c5c0cb8c4391c6cbdd91515e to your computer and use it in GitHub Desktop.
This file contains 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 { graphql, QueryRenderer } from 'react-relay'; | |
function withRelayContainer(WrappedComponent, selectData) { | |
return ({environment, variables, router}) => | |
<QueryRenderer | |
environment={environment} | |
query={graphql` | |
query PollsContainerQuery($id: ID!) { | |
question(id: $id) { | |
id | |
...PollsVote_question | |
...PollsResults_question | |
} | |
} | |
`} | |
variables={{ id: router.match.params.id }} | |
render={({ error, props }) => props ? | |
<WrappedComponent | |
{...props} | |
router={router} | |
environment={environment} | |
initialVariables={{ id: router.match.params.id }} | |
/> : | |
<div>loading...</div> } | |
/> | |
} | |
export default withRelayContainer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment