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

Function updateWrapper

code/styling/public/app.js:4516–4556  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

4514}
4515
4516function updateWrapper(element, props) {
4517 var node = element;
4518 {
4519 var _controlled = isControlled(props);
4520
4521 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
4522 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());
4523 didWarnUncontrolledToControlled = true;
4524 }
4525 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
4526 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());
4527 didWarnControlledToUncontrolled = true;
4528 }
4529 }
4530
4531 updateChecked(element, props);
4532
4533 var value = getSafeValue(props.value);
4534
4535 if (value != null) {
4536 if (props.type === 'number') {
4537 if (value === 0 && node.value === '' ||
4538 // eslint-disable-next-line
4539 node.value != value) {
4540 node.value = '' + value;
4541 }
4542 } else if (node.value !== '' + value) {
4543 node.value = '' + value;
4544 }
4545 }
4546
4547 if (props.hasOwnProperty('value')) {
4548 setDefaultValue(node, props.type, value);
4549 } else if (props.hasOwnProperty('defaultValue')) {
4550 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
4551 }
4552
4553 if (props.checked == null && props.defaultChecked != null) {
4554 node.defaultChecked = !!props.defaultChecked;
4555 }
4556}
4557
4558function postMountWrapper(element, props) {
4559 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