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

Function updateWrapper

code/communication/public/app.js:4551–4591  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

4549}
4550
4551function updateWrapper(element, props) {
4552 var node = element;
4553 {
4554 var _controlled = isControlled(props);
4555
4556 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
4557 warning(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum());
4558 didWarnUncontrolledToControlled = true;
4559 }
4560 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
4561 warning(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum());
4562 didWarnControlledToUncontrolled = true;
4563 }
4564 }
4565
4566 updateChecked(element, props);
4567
4568 var value = getSafeValue(props.value);
4569
4570 if (value != null) {
4571 if (props.type === 'number') {
4572 if (value === 0 && node.value === '' ||
4573 // eslint-disable-next-line
4574 node.value != value) {
4575 node.value = '' + value;
4576 }
4577 } else if (node.value !== '' + value) {
4578 node.value = '' + value;
4579 }
4580 }
4581
4582 if (props.hasOwnProperty('value')) {
4583 setDefaultValue(node, props.type, value);
4584 } else if (props.hasOwnProperty('defaultValue')) {
4585 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
4586 }
4587
4588 if (props.checked == null && props.defaultChecked != null) {
4589 node.defaultChecked = !!props.defaultChecked;
4590 }
4591}
4592
4593function postMountWrapper(element, props) {
4594 var node = element;

Callers 3

restoreControlledStateFunction · 0.70
updateNamedCousinsFunction · 0.70
updateProperties$1Function · 0.70

Calls 5

warningFunction · 0.85
isControlledFunction · 0.70
updateCheckedFunction · 0.70
getSafeValueFunction · 0.70
setDefaultValueFunction · 0.70

Tested by

no test coverage detected