MCPcopy Create free account
hub / github.com/docker/getting-started / createReactContext

Function createReactContext

app/src/static/js/react-bootstrap.js:8530–8654  ·  view source on GitHub ↗
(defaultValue, calculateChangedBits)

Source from the content-addressed store, hash-verified

8528}
8529
8530function createReactContext(defaultValue, calculateChangedBits) {
8531 var _Provider$childContex, _Consumer$contextType;
8532
8533 var contextProp = '__create-react-context-' + (0, _gud2.default)() + '__';
8534
8535 var Provider = function (_Component) {
8536 _inherits(Provider, _Component);
8537
8538 function Provider() {
8539 var _temp, _this, _ret;
8540
8541 _classCallCheck(this, Provider);
8542
8543 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
8544 args[_key] = arguments[_key];
8545 }
8546
8547 return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.emitter = createEventEmitter(_this.props.value), _temp), _possibleConstructorReturn(_this, _ret);
8548 }
8549
8550 Provider.prototype.getChildContext = function getChildContext() {
8551 var _ref;
8552
8553 return _ref = {}, _ref[contextProp] = this.emitter, _ref;
8554 };
8555
8556 Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
8557 if (this.props.value !== nextProps.value) {
8558 var oldValue = this.props.value;
8559 var newValue = nextProps.value;
8560 var changedBits = void 0;
8561
8562 if (objectIs(oldValue, newValue)) {
8563 changedBits = 0; // No change
8564 } else {
8565 changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
8566
8567 if (false) {}
8568
8569 changedBits |= 0;
8570
8571 if (changedBits !== 0) {
8572 this.emitter.set(nextProps.value, changedBits);
8573 }
8574 }
8575 }
8576 };
8577
8578 Provider.prototype.render = function render() {
8579 return this.props.children;
8580 };
8581
8582 return Provider;
8583 }(_react.Component);
8584
8585 Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = _propTypes2.default.object.isRequired, _Provider$childContex);
8586
8587 var Consumer = function (_Component2) {

Callers

nothing calls this directly

Calls 3

_inheritsFunction · 0.85
objectIsFunction · 0.85
onlyChildFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…