1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-relay-modern-server-express/lib/RelayProvider.js
Diogo Dutra a996fba09c Added a new example with relay modern and a graphql server with express. (#4670)
* Added a new example with relay modern and a graphql server with express.

* removed .graphqlconfig file from with-relay-modern-server-express example
2018-12-10 16:50:35 +01:00

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