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

Function updateWrapper

code/controlled-uncontrolled/public/app.js:3840–3880  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

3838}
3839
3840function updateWrapper(element, props) {
3841 var node = element;
3842 {
3843 var _controlled = isControlled(props);
3844
3845 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
3846 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());
3847 didWarnUncontrolledToControlled = true;
3848 }
3849 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
3850 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());
3851 didWarnControlledToUncontrolled = true;
3852 }
3853 }
3854
3855 updateChecked(element, props);
3856
3857 var value = getSafeValue(props.value);
3858
3859 if (value != null) {
3860 if (props.type === 'number') {
3861 if (value === 0 && node.value === '' ||
3862 // eslint-disable-next-line
3863 node.value != value) {
3864 node.value = '' + value;
3865 }
3866 } else if (node.value !== '' + value) {
3867 node.value = '' + value;
3868 }
3869 }
3870
3871 if (props.hasOwnProperty('value')) {
3872 setDefaultValue(node, props.type, value);
3873 } else if (props.hasOwnProperty('defaultValue')) {
3874 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
3875 }
3876
3877 if (props.checked == null && props.defaultChecked != null) {
3878 node.defaultChecked = !!props.defaultChecked;
3879 }
3880}
3881
3882function postMountWrapper(element, props) {
3883 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