2018-04-03 07:34:07 +00:00
|
|
|
/* eslint-disable */
|
2018-03-06 13:27:47 +00:00
|
|
|
import { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
import { Provider } from 'react-fela'
|
|
|
|
import getFelaRenderer from './getFelaRenderer'
|
|
|
|
|
|
|
|
const clientRenderer = getFelaRenderer()
|
|
|
|
|
|
|
|
export default class FelaProvider extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
renderer: PropTypes.object
|
2018-12-17 16:34:32 +00:00
|
|
|
}
|
2018-03-06 13:27:47 +00:00
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
render() {
|
2018-03-06 13:27:47 +00:00
|
|
|
if (this.context.renderer) {
|
|
|
|
return this.props.children
|
|
|
|
}
|
|
|
|
|
|
|
|
const renderer = this.props.renderer || clientRenderer
|
2018-12-17 16:34:32 +00:00
|
|
|
return <Provider renderer={renderer}>{this.props.children}</Provider>
|
2018-03-06 13:27:47 +00:00
|
|
|
}
|
|
|
|
}
|