@samitouri / QOS-React / commits / cbef3fd412

Warn it only in DEV (#9772)

Toru Kobayashi committed May 25, 2017 at 23:31 UTC cbef3fd41228040eb580bb1298f91cd9fbce24f9
1 file changed +25 -22
src/renderers/shared/server/ReactServerRenderer.js
+25 -22
@@ -116,12 +116,16 @@ function flattenOptionChildren(children) {
116 }
117 if (typeof child === 'string' || typeof child === 'number') {
118 content += child;
119 - } else if (!didWarnInvalidOptionChildren) {
120 - didWarnInvalidOptionChildren = true;
121 - warning(
122 - false,
123 - 'Only strings and numbers are supported as <option> children.',
124 - );
119 + } else {
120 + if (__DEV__) {
121 + if (!didWarnInvalidOptionChildren) {
122 + didWarnInvalidOptionChildren = true;
123 + warning(
124 + false,
125 + 'Only strings and numbers are supported as <option> children.',
126 + );
127 + }
128 + }
129 }
130 });
131 return content;
@@ -547,24 +551,23 @@ class ReactDOMServerRenderer {
551 );
552 }
553 }
550 - }
554
552 - if (
553 - props.value !== undefined &&
554 - props.defaultValue !== undefined &&
555 - !didWarnDefaultSelectValue
556 - ) {
557 - warning(
558 - false,
559 - 'Select elements must be either controlled or uncontrolled ' +
560 - '(specify either the value prop, or the defaultValue prop, but not ' +
561 - 'both). Decide between using a controlled or uncontrolled select ' +
562 - 'element and remove one of these props. More info: ' +
563 - 'https://fb.me/react-controlled-components',
564 - );
565 - didWarnDefaultSelectValue = true;
555 + if (
556 + props.value !== undefined &&
557 + props.defaultValue !== undefined &&
558 + !didWarnDefaultSelectValue
559 + ) {
560 + warning(
561 + false,
562 + 'Select elements must be either controlled or uncontrolled ' +
563 + '(specify either the value prop, or the defaultValue prop, but not ' +
564 + 'both). Decide between using a controlled or uncontrolled select ' +
565 + 'element and remove one of these props. More info: ' +
566 + 'https://fb.me/react-controlled-components',
567 + );
568 + didWarnDefaultSelectValue = true;
569 + }
570 }
567 -
571 this.currentSelectValue = props.value != null
572 ? props.value
573 : props.defaultValue;