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

Function updateWrapper

code/new-context-api/public/app.js:3877–3917  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

3875}
3876
3877function updateWrapper(element, props) {
3878 var node = element;
3879 {
3880 var _controlled = isControlled(props);
3881
3882 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
3883 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());
3884 didWarnUncontrolledToControlled = true;
3885 }
3886 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
3887 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());
3888 didWarnControlledToUncontrolled = true;
3889 }
3890 }
3891
3892 updateChecked(element, props);
3893
3894 var value = getSafeValue(props.value);
3895
3896 if (value != null) {
3897 if (props.type === 'number') {
3898 if (value === 0 && node.value === '' ||
3899 // eslint-disable-next-line
3900 node.value != value) {
3901 node.value = '' + value;
3902 }
3903 } else if (node.value !== '' + value) {
3904 node.value = '' + value;
3905 }
3906 }
3907
3908 if (props.hasOwnProperty('value')) {
3909 setDefaultValue(node, props.type, value);
3910 } else if (props.hasOwnProperty('defaultValue')) {
3911 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
3912 }
3913
3914 if (props.checked == null && props.defaultChecked != null) {
3915 node.defaultChecked = !!props.defaultChecked;
3916 }
3917}
3918
3919function postMountWrapper(element, props) {
3920 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