@samitouri / QOS-React / commits / 2418f24b60

Fix <select> check of defaultValue/value type (#21611)

Sebastian Markbåge committed Jun 3, 2021 at 09:13 UTC 2418f24b609029c3f3415b5954005d5aa4851f0b
1 file changed +16 -13
packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+16 -13
@@ -568,19 +568,22 @@ let didWarnSelectedSetOnOption = false;
568
569 function checkSelectProp(props, propName) {
570 if (__DEV__) {
571 - const array = isArray(props[propName]);
572 - if (props.multiple && !array) {
573 - console.error(
574 - 'The `%s` prop supplied to <select> must be an array if ' +
575 - '`multiple` is true.',
576 - propName,
577 - );
578 - } else if (!props.multiple && array) {
579 - console.error(
580 - 'The `%s` prop supplied to <select> must be a scalar ' +
581 - 'value if `multiple` is false.',
582 - propName,
583 - );
571 + const value = props[propName];
572 + if (value != null) {
573 + const array = isArray(value);
574 + if (props.multiple && !array) {
575 + console.error(
576 + 'The `%s` prop supplied to <select> must be an array if ' +
577 + '`multiple` is true.',
578 + propName,
579 + );
580 + } else if (!props.multiple && array) {
581 + console.error(
582 + 'The `%s` prop supplied to <select> must be a scalar ' +
583 + 'value if `multiple` is false.',
584 + propName,
585 + );
586 + }
587 }
588 }
589 }