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

Function updateWrapper

code/redux/public/app.js:4767–4807  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

4765}
4766
4767function updateWrapper(element, props) {
4768 var node = element;
4769 {
4770 var _controlled = isControlled(props);
4771
4772 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
4773 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());
4774 didWarnUncontrolledToControlled = true;
4775 }
4776 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
4777 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());
4778 didWarnControlledToUncontrolled = true;
4779 }
4780 }
4781
4782 updateChecked(element, props);
4783
4784 var value = getSafeValue(props.value);
4785
4786 if (value != null) {
4787 if (props.type === 'number') {
4788 if (value === 0 && node.value === '' ||
4789 // eslint-disable-next-line
4790 node.value != value) {
4791 node.value = '' + value;
4792 }
4793 } else if (node.value !== '' + value) {
4794 node.value = '' + value;
4795 }
4796 }
4797
4798 if (props.hasOwnProperty('value')) {
4799 setDefaultValue(node, props.type, value);
4800 } else if (props.hasOwnProperty('defaultValue')) {
4801 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
4802 }
4803
4804 if (props.checked == null && props.defaultChecked != null) {
4805 node.defaultChecked = !!props.defaultChecked;
4806 }
4807}
4808
4809function postMountWrapper(element, props) {
4810 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