Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 27x 27x 27x 7x 5x 27x 27x 27x | import * as React from 'react'; import * as PropTypes from 'prop-types'; import ApolloClient from 'apollo-client'; const invariant = require('invariant'); export interface ApolloConsumerProps { children: (client: ApolloClient<any>) => React.ReactElement<any> | null; } const ApolloConsumer: React.StatelessComponent<ApolloConsumerProps> = (props, context) => { invariant( !!context.client, `Could not find "client" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>`, ); return props.children(context.client); }; ApolloConsumer.contextTypes = { client: PropTypes.object.isRequired, }; ApolloConsumer.propTypes = { children: PropTypes.func.isRequired, }; export default ApolloConsumer; |