Skip to content

Instantly share code, notes, and snippets.

@peggyrayzis
Last active June 3, 2017 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peggyrayzis/65f1f771216c021a9991a9a93e747423 to your computer and use it in GitHub Desktop.
Save peggyrayzis/65f1f771216c021a9991a9a93e747423 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import { MatchSummary, NoDataSummary } from '@mls-digital/react-components';
import MatchSummaryQuery from './match-summary.graphql';
// here we're using the graphql HOC as a decorator, but you can use it as a function too!
@graphql(MatchSummaryQuery, {
options: ({ id, season, shouldPoll }) => {
return {
variables: {
id,
season,
},
pollInterval: shouldPoll ? 1000 * 60 : undefined,
};
};
})
class MatchSummaryContainer extends Component {
render() {
const { data: { loading, match } } = this.props;
if (loading && !match) {
return <NoDataSummary />;
}
return <MatchSummary {...match} />;
}
}
export default MatchSummaryContainer;
@jbaxleyiii
Copy link

const { loading, ...matchSummaryProps } = this.props;

Wouldn't this come in as this.props.data?

@peggyrayzis
Copy link
Author

Yes you're totally right, good catch! I forgot to convert that since the next section is where I map the results to new props. 😀 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment