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

Function updateWrapper

code/composition/public/app.js:4654–4694  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

4652}
4653
4654function updateWrapper(element, props) {
4655 var node = element;
4656 {
4657 var _controlled = isControlled(props);
4658
4659 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
4660 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());
4661 didWarnUncontrolledToControlled = true;
4662 }
4663 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
4664 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());
4665 didWarnControlledToUncontrolled = true;
4666 }
4667 }
4668
4669 updateChecked(element, props);
4670
4671 var value = getSafeValue(props.value);
4672
4673 if (value != null) {
4674 if (props.type === 'number') {
4675 if (value === 0 && node.value === '' ||
4676 // eslint-disable-next-line
4677 node.value != value) {
4678 node.value = '' + value;
4679 }
4680 } else if (node.value !== '' + value) {
4681 node.value = '' + value;
4682 }
4683 }
4684
4685 if (props.hasOwnProperty('value')) {
4686 setDefaultValue(node, props.type, value);
4687 } else if (props.hasOwnProperty('defaultValue')) {
4688 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
4689 }
4690
4691 if (props.checked == null && props.defaultChecked != null) {
4692 node.defaultChecked = !!props.defaultChecked;
4693 }
4694}
4695
4696function postMountWrapper(element, props) {
4697 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