Skip to content

Commit 1ae5527

Browse files
author
刘欢
committed
feat: change useSearchConfig1
1 parent d6626df commit 1ae5527

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/hooks/useSearchConfig.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,26 @@ export default function useSearchConfig(
1313
filterSort,
1414
onSearch,
1515
autoClearSearchValue,
16-
} = props || {};
16+
} = props;
1717
return React.useMemo<[boolean | undefined, SearchConfig<DefaultOptionType>]>(() => {
18-
const legacyShowSearch: SearchConfig<DefaultOptionType> = {
18+
const searchConfig = {
1919
filterOption,
2020
searchValue,
2121
optionFilterProp,
2222
filterSort,
2323
onSearch,
2424
autoClearSearchValue,
25+
...(typeof showSearch === 'object' ? showSearch : {}),
2526
};
2627

27-
if (showSearch === undefined || showSearch === true) {
28-
return [showSearch as undefined | boolean, legacyShowSearch];
29-
}
30-
if (!showSearch) {
28+
if (showSearch === false) {
3129
return [false, {}];
3230
}
33-
const searchConfig = {
34-
...legacyShowSearch,
35-
...showSearch,
36-
};
31+
32+
if (showSearch === undefined) {
33+
return [undefined, searchConfig];
34+
}
35+
3736
return [true, searchConfig];
3837
}, [
3938
showSearch,

0 commit comments

Comments
 (0)