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

Function updateWrapper

code/higher-order-components/public/app.js:4510–4550  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

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