Skip to content

Instantly share code, notes, and snippets.

@peggyrayzis
Created June 2, 2017 17:02
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/bcb69c07a0da23c4350dee6d7bc9fb90 to your computer and use it in GitHub Desktop.
Save peggyrayzis/bcb69c07a0da23c4350dee6d7bc9fb90 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { compose, graphql } from 'react-apollo';
import { NoDataExtension } from '@mls-digital/react-components';
import PostGameExtension from './post-game';
import PreGameExtension from './pre-game';
import PostGameQuery from './post-game.graphql';
import PreGameQuery from './pre-game.graphql';
@compose(
graphql(PreGameQuery, {
skip: ({ gameStatus }) => gameStatus !== 'pre',
props: ({ data }) => ({
preGameLoading: data.loading,
preGameProps: data.match,
}),
}),
graphql(PostGameQuery, {
skip: ({ gameStatus }) => gameStatus !== 'post',
props: ({ data }) => ({
postGameLoading: data.loading,
postGameProps: data.match,
}),
}),
)
export default class MatchExtensionContainer extends Component {
render() {
const {
preGameLoading,
postGameLoading,
gameStatus,
preGameProps,
postGameProps,
...rest
} = this.props;
if (preGameLoading || postGameLoading)
return <NoDataExtension gameStatus={gameStatus} />;
return gameStatus === 'post'
? <PostGameExtension {...postGameProps} {...rest} />;
: <PreGameExtension {...preGameProps} {...rest} />;
}
}
@japrogramer
Copy link

hi, Im getting a SyntaxError when I try to pass this file thru a linter called prettier

[error] src/compo_boiler.js: SyntaxError: Unexpected token, expected : (40:59)
[error]   38 |
[error]   39 |     return gameStatus === 'post'
[error] > 40 |       ? <PostGameExtension {...postGameProps} {...rest} />;
[error]      |                                                           ^
[error]   41 |       : <PreGameExtension {...preGameProps} {...rest} />;
[error]   42 |   }
[error]   43 | }

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