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

Function uncontrollable

app/src/static/js/react-bootstrap.js:314–465  ·  view source on GitHub ↗
(Component, controlledValues, methods)

Source from the content-addressed store, hash-verified

312}
313
314function uncontrollable(Component, controlledValues, methods) {
315 if (methods === void 0) {
316 methods = [];
317 }
318
319 var displayName = Component.displayName || Component.name || 'Component';
320 var canAcceptRef = Utils.canAcceptRef(Component);
321 var controlledProps = Object.keys(controlledValues);
322 var PROPS_TO_OMIT = controlledProps.map(Utils.defaultKey);
323 !(canAcceptRef || !methods.length) ? false ? undefined : invariant(false) : void 0;
324
325 var UncontrolledComponent =
326 /*#__PURE__*/
327 function (_React$Component) {
328 _inheritsLoose(UncontrolledComponent, _React$Component);
329
330 function UncontrolledComponent() {
331 var _this;
332
333 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
334 args[_key] = arguments[_key];
335 }
336
337 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
338 _this.handlers = Object.create(null);
339 controlledProps.forEach(function (propName) {
340 var handlerName = controlledValues[propName];
341
342 var handleChange = function handleChange(value) {
343 if (_this.props[handlerName]) {
344 var _this$props;
345
346 _this._notifying = true;
347
348 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
349 args[_key2 - 1] = arguments[_key2];
350 }
351
352 (_this$props = _this.props)[handlerName].apply(_this$props, [value].concat(args));
353
354 _this._notifying = false;
355 }
356
357 _this._values[propName] = value;
358 if (!_this.unmounted) _this.forceUpdate();
359 };
360
361 _this.handlers[handlerName] = handleChange;
362 });
363 if (methods.length) _this.attachRef = function (ref) {
364 _this.inner = ref;
365 };
366 return _this;
367 }
368
369 var _proto = UncontrolledComponent.prototype;
370
371 _proto.shouldComponentUpdate = function shouldComponentUpdate() {

Callers

nothing calls this directly

Calls 4

invariantFunction · 0.85
_inheritsLooseFunction · 0.85
_extendsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…