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/lib/RelayProvider.js

32 lines
663 B
JavaScript
Raw Normal View History

2017-08-14 16:41:12 +00:00
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