refactor: use instanceof instead typeof

This commit is contained in:
Wei Zhu 2018-09-30 17:04:05 +08:00
parent 2bf2bb5af4
commit ff0595733f
2 changed files with 4 additions and 4 deletions

View File

@ -831,8 +831,8 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
renderColumnTitle(title: ColumnProps<T>['title']) { renderColumnTitle(title: ColumnProps<T>['title']) {
const { filters, sortOrder } = this.state; const { filters, sortOrder } = this.state;
// https://github.com/ant-design/ant-design/issues/11246#issuecomment-405009167 // https://github.com/ant-design/ant-design/issues/11246#issuecomment-405009167
if (typeof title === 'function') { if (title instanceof Function) {
return (title as Function)({ return title({
filters, filters,
sortOrder, sortOrder,
}); });

View File

@ -219,8 +219,8 @@ export default class FilterMenu<T> extends React.Component<FilterMenuProps<T>, F
[`${dropdownPrefixCls}-menu-without-submenu`]: !this.hasSubMenu(), [`${dropdownPrefixCls}-menu-without-submenu`]: !this.hasSubMenu(),
}); });
let { filterDropdown } = column; let { filterDropdown } = column;
if (typeof filterDropdown === 'function') { if (filterDropdown instanceof Function) {
filterDropdown = (filterDropdown as Function)({ filterDropdown = filterDropdown({
prefixCls: `${dropdownPrefixCls}-custom`, prefixCls: `${dropdownPrefixCls}-custom`,
setSelectedKeys: (selectedKeys: Array<any>) => this.setSelectedKeys({ selectedKeys }), setSelectedKeys: (selectedKeys: Array<any>) => this.setSelectedKeys({ selectedKeys }),
selectedKeys: this.state.selectedKeys, selectedKeys: this.state.selectedKeys,