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

Function updateWrapper

code/dependency-injection/public/app.js:4609–4649  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

4607}
4608
4609function updateWrapper(element, props) {
4610 var node = element;
4611 {
4612 var _controlled = isControlled(props);
4613
4614 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
4615 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());
4616 didWarnUncontrolledToControlled = true;
4617 }
4618 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
4619 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());
4620 didWarnControlledToUncontrolled = true;
4621 }
4622 }
4623
4624 updateChecked(element, props);
4625
4626 var value = getSafeValue(props.value);
4627
4628 if (value != null) {
4629 if (props.type === 'number') {
4630 if (value === 0 && node.value === '' ||
4631 // eslint-disable-next-line
4632 node.value != value) {
4633 node.value = '' + value;
4634 }
4635 } else if (node.value !== '' + value) {
4636 node.value = '' + value;
4637 }
4638 }
4639
4640 if (props.hasOwnProperty('value')) {
4641 setDefaultValue(node, props.type, value);
4642 } else if (props.hasOwnProperty('defaultValue')) {
4643 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
4644 }
4645
4646 if (props.checked == null && props.defaultChecked != null) {
4647 node.defaultChecked = !!props.defaultChecked;
4648 }
4649}
4650
4651function postMountWrapper(element, props) {
4652 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