Skip to content

Instantly share code, notes, and snippets.

@peaonunes
Last active October 10, 2018 02:00
Show Gist options
  • Select an option

  • Save peaonunes/42f8079f08e87c8dd311e5737d23609b to your computer and use it in GitHub Desktop.

Select an option

Save peaonunes/42f8079f08e87c8dd311e5737d23609b to your computer and use it in GitHub Desktop.
import { Query } from 'react-apollo'
import PropTypes from 'prop-types'
import React from 'react'
import { queryEnabledFeatures } from './graphql/query'
class EnabledFeatures extends React.Component {
static propTypes = {
children: PropTypes.func.isRequired
}
render() {
const { children } = this.props
return (
<Query query={queryEnabledFeatures}>
{({ loading, error, data }) => {
let renderProps = {
loading,
error,
ready: false
}
if (!data) return children({ ...renderProps })
return children({ ...renderProps, ready: true })
}}
</Query>
)
}
}
export default EnabledFeatures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment