MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / initWrapperState$2

Function initWrapperState$2

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

Source from the content-addressed store, hash-verified

14038}
14039
14040function initWrapperState$2(element, props) {
14041 var node = element;
14042 {
14043 ReactControlledValuePropTypes.checkPropTypes('textarea', props, getCurrentFiberStackAddendum$5);
14044 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
14045 warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
14046 didWarnValDefaultVal = true;
14047 }
14048 }
14049
14050 var initialValue = props.value;
14051
14052 // Only bother fetching default value if we're going to use it
14053 if (initialValue == null) {
14054 var defaultValue = props.defaultValue;
14055 // TODO (yungsters): Remove support for children content in <textarea>.
14056 var children = props.children;
14057 if (children != null) {
14058 {
14059 warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
14060 }
14061 !(defaultValue == null) ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0;
14062 if (Array.isArray(children)) {
14063 !(children.length <= 1) ? invariant(false, '<textarea> can only have at most one child.') : void 0;
14064 children = children[0];
14065 }
14066
14067 defaultValue = '' + children;
14068 }
14069 if (defaultValue == null) {
14070 defaultValue = '';
14071 }
14072 initialValue = defaultValue;
14073 }
14074
14075 node._wrapperState = {
14076 initialValue: '' + initialValue
14077 };
14078}
14079
14080function updateWrapper$1(element, props) {
14081 var node = element;

Callers 2

setInitialProperties$1Function · 0.70
diffHydratedProperties$1Function · 0.70

Calls 2

warningFunction · 0.85
invariantFunction · 0.70

Tested by

no test coverage detected