MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / createProvider

Function createProvider

code/redux/public/app.js:18608–18656  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18606}
18607
18608function createProvider() {
18609 var _Provider$childContex;
18610
18611 var storeKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'store';
18612 var subKey = arguments[1];
18613
18614 var subscriptionKey = subKey || storeKey + 'Subscription';
18615
18616 var Provider = function (_Component) {
18617 _inherits(Provider, _Component);
18618
18619 Provider.prototype.getChildContext = function getChildContext() {
18620 var _ref;
18621
18622 return _ref = {}, _ref[storeKey] = this[storeKey], _ref[subscriptionKey] = null, _ref;
18623 };
18624
18625 function Provider(props, context) {
18626 _classCallCheck(this, Provider);
18627
18628 var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
18629
18630 _this[storeKey] = props.store;
18631 return _this;
18632 }
18633
18634 Provider.prototype.render = function render() {
18635 return _react.Children.only(this.props.children);
18636 };
18637
18638 return Provider;
18639 }(_react.Component);
18640
18641 if (process.env.NODE_ENV !== 'production') {
18642 Provider.prototype.componentWillReceiveProps = function (nextProps) {
18643 if (this[storeKey] !== nextProps.store) {
18644 warnAboutReceivingStore();
18645 }
18646 };
18647 }
18648
18649 Provider.propTypes = {
18650 store: _PropTypes.storeShape.isRequired,
18651 children: _propTypes2.default.element.isRequired
18652 };
18653 Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[storeKey] = _PropTypes.storeShape.isRequired, _Provider$childContex[subscriptionKey] = _PropTypes.subscriptionShape, _Provider$childContex);
18654
18655 return Provider;
18656}
18657
18658exports.default = createProvider();
18659}).call(this,require('_process'))

Callers 1

app.jsFile · 0.85

Calls 2

warnAboutReceivingStoreFunction · 0.85
_inheritsFunction · 0.70

Tested by

no test coverage detected