Skip to content

Commit

Permalink
fix: off topic
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 21, 2024
1 parent e230c2d commit 6b767b1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import LegacyContext from './LegacyContext';
import TreeSelectContext from './TreeSelectContext';
import type { Key, SafeKey } from './interface';
import { getAllKeys, isCheckDisabled } from './utils/valueUtil';
import { useEvent } from 'rc-util';

const HIDDEN_STYLE = {
width: 0,
Expand Down Expand Up @@ -241,17 +242,13 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
onKeyUp: () => {},
}));

const syncLoadData = useEvent(loadData);

const loadDataFun = useMemo(
() => (searchValue ? null : (loadData as any)),
[loadData, searchValue, treeExpandedKeys || expandedKeys],
(
[prevLoadData, preSearchValue],
[nextLoadData, nextSearchValue, nextExcludeSearchExpandedKeys],
) =>
// `loadData` changed
prevLoadData !== nextLoadData ||
// `searchValue` changed and not in search mode
(preSearchValue !== nextSearchValue && !!(nextSearchValue || nextExcludeSearchExpandedKeys)),
() => (searchValue ? null : (syncLoadData as any)),
[searchValue, treeExpandedKeys || expandedKeys],
([preSearchValue], [nextSearchValue, nextExcludeSearchExpandedKeys]) =>
preSearchValue !== nextSearchValue && !!(nextSearchValue || nextExcludeSearchExpandedKeys),
);

// ========================== Render ==========================
Expand Down

0 comments on commit 6b767b1

Please sign in to comment.