Skip to content

Commit

Permalink
Fix <select> check of defaultValue/value type (#21611)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jun 3, 2021
1 parent 154a8cf commit 2418f24
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,19 +568,22 @@ let didWarnSelectedSetOnOption = false;

function checkSelectProp(props, propName) {
if (__DEV__) {
const array = isArray(props[propName]);
if (props.multiple && !array) {
console.error(
'The `%s` prop supplied to <select> must be an array if ' +
'`multiple` is true.',
propName,
);
} else if (!props.multiple && array) {
console.error(
'The `%s` prop supplied to <select> must be a scalar ' +
'value if `multiple` is false.',
propName,
);
const value = props[propName];
if (value != null) {
const array = isArray(value);
if (props.multiple && !array) {
console.error(
'The `%s` prop supplied to <select> must be an array if ' +
'`multiple` is true.',
propName,
);
} else if (!props.multiple && array) {
console.error(
'The `%s` prop supplied to <select> must be a scalar ' +
'value if `multiple` is false.',
propName,
);
}
}
}
}
Expand Down

0 comments on commit 2418f24

Please sign in to comment.