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

Function updateWrapper

code/third-party/public/app.js:3749–3789  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

3747}
3748
3749function updateWrapper(element, props) {
3750 var node = element;
3751 {
3752 var _controlled = isControlled(props);
3753
3754 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
3755 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());
3756 didWarnUncontrolledToControlled = true;
3757 }
3758 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
3759 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());
3760 didWarnControlledToUncontrolled = true;
3761 }
3762 }
3763
3764 updateChecked(element, props);
3765
3766 var value = getSafeValue(props.value);
3767
3768 if (value != null) {
3769 if (props.type === 'number') {
3770 if (value === 0 && node.value === '' ||
3771 // eslint-disable-next-line
3772 node.value != value) {
3773 node.value = '' + value;
3774 }
3775 } else if (node.value !== '' + value) {
3776 node.value = '' + value;
3777 }
3778 }
3779
3780 if (props.hasOwnProperty('value')) {
3781 setDefaultValue(node, props.type, value);
3782 } else if (props.hasOwnProperty('defaultValue')) {
3783 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
3784 }
3785
3786 if (props.checked == null && props.defaultChecked != null) {
3787 node.defaultChecked = !!props.defaultChecked;
3788 }
3789}
3790
3791function postMountWrapper(element, props) {
3792 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