mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix <select> check of defaultValue/value type (#21611)
This commit is contained in:
+16
-13
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user