diff --git a/package.json b/package.json index f6be5af72..0f0c2a088 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "rc-animate": "2.x", "rc-menu": "4.x", "rc-trigger": "1.x", - "rc-util": "3.x" + "rc-util": "3.x", + "warning": "^2.1.0" }, "pre-commit": [ "lint" diff --git a/src/FilterMixin.js b/src/FilterMixin.js index 07f39ec8c..07387a4be 100644 --- a/src/FilterMixin.js +++ b/src/FilterMixin.js @@ -1,7 +1,9 @@ import React from 'react'; -import OptGroup from './OptGroup'; import { getValuePropValue, UNSELECTABLE_ATTRIBUTE, UNSELECTABLE_STYLE } from './util'; import { Item as MenuItem, ItemGroup as MenuItemGroup } from 'rc-menu'; +import warning from 'warning'; +import OptGroup from './OptGroup'; +import Option from './Option'; export default { filterOption(input, child) { @@ -44,6 +46,13 @@ export default { } return; } + + warning( + child.type === Option, + 'the children of `Select` should be `Select.Option` or `Select.OptGroup`, ' + + `instead of \`${child.type.name || child.type.displayName || child.type}\`.` + ); + const childValue = getValuePropValue(child); if (this.filterOption(inputValue, child)) { sel.push(