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']) {
const { filters, sortOrder } = this.state;
// https://github.com/ant-design/ant-design/issues/11246#issuecomment-405009167
if (typeof title === 'function') {
return (title as Function)({
if (title instanceof Function) {
return title({
filters,
sortOrder,
});

View File

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