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

Function updateWrapper

code/one-direction-data-flow/public/app.js:4389–4429  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

4387}
4388
4389function updateWrapper(element, props) {
4390 var node = element;
4391 {
4392 var _controlled = isControlled(props);
4393
4394 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
4395 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());
4396 didWarnUncontrolledToControlled = true;
4397 }
4398 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
4399 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());
4400 didWarnControlledToUncontrolled = true;
4401 }
4402 }
4403
4404 updateChecked(element, props);
4405
4406 var value = getSafeValue(props.value);
4407
4408 if (value != null) {
4409 if (props.type === 'number') {
4410 if (value === 0 && node.value === '' ||
4411 // eslint-disable-next-line
4412 node.value != value) {
4413 node.value = '' + value;
4414 }
4415 } else if (node.value !== '' + value) {
4416 node.value = '' + value;
4417 }
4418 }
4419
4420 if (props.hasOwnProperty('value')) {
4421 setDefaultValue(node, props.type, value);
4422 } else if (props.hasOwnProperty('defaultValue')) {
4423 setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
4424 }
4425
4426 if (props.checked == null && props.defaultChecked != null) {
4427 node.defaultChecked = !!props.defaultChecked;
4428 }
4429}
4430
4431function postMountWrapper(element, props) {
4432 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