mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
a996fba09c
* Added a new example with relay modern and a graphql server with express. * removed .graphqlconfig file from with-relay-modern-server-express example
32 lines
663 B
JavaScript
32 lines
663 B
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
|
|
// Thank you https://github.com/robrichard
|
|
// https://github.com/robrichard/relay-context-provider
|
|
|
|
class RelayProvider extends React.Component {
|
|
getChildContext () {
|
|
return {
|
|
relay: {
|
|
environment: this.props.environment,
|
|
variables: this.props.variables
|
|
}
|
|
}
|
|
}
|
|
render () {
|
|
return this.props.children
|
|
}
|
|
}
|
|
|
|
RelayProvider.childContextTypes = {
|
|
relay: PropTypes.object.isRequired
|
|
}
|
|
|
|
RelayProvider.propTypes = {
|
|
environment: PropTypes.object.isRequired,
|
|
variables: PropTypes.object.isRequired,
|
|
children: PropTypes.node
|
|
}
|
|
|
|
export default RelayProvider
|