Skip to content

Commit f015c60

Browse files
author
刘欢
committed
feat: change useSearchConfig
1 parent df15a38 commit f015c60

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/hooks/useSearchConfig.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,18 @@ export default function useSearchConfig(
1515
treeNodeFilterProp,
1616
} = props;
1717
return React.useMemo<[boolean | undefined, SearchConfig]>(() => {
18+
const isObject = typeof showSearch === 'object';
19+
1820
const searchConfig: SearchConfig = {
1921
searchValue: searchValue ?? inputValue,
2022
onSearch,
2123
autoClearSearchValue,
2224
filterTreeNode,
2325
treeNodeFilterProp,
24-
...(typeof showSearch === 'object' ? showSearch : {}),
26+
...(isObject ? showSearch : {}),
2527
};
26-
if (showSearch === false) {
27-
return [false, {}];
28-
}
29-
30-
if (showSearch === undefined) {
31-
return [undefined, searchConfig];
32-
}
3328

34-
return [true, searchConfig];
29+
return [isObject ? true : showSearch, searchConfig];
3530
}, [
3631
showSearch,
3732
searchValue,

0 commit comments

Comments
 (0)