Skip to content

Commit 4666347

Browse files
committed
fix: sync load logic
1 parent 6b767b1 commit 4666347

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/OptionList.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
242242
onKeyUp: () => {},
243243
}));
244244

245-
const syncLoadData = useEvent(loadData);
246-
247-
const loadDataFun = useMemo(
248-
() => (searchValue ? null : (syncLoadData as any)),
245+
const hasLoadDataFn = useMemo(
246+
() => (searchValue ? false : true),
249247
[searchValue, treeExpandedKeys || expandedKeys],
250248
([preSearchValue], [nextSearchValue, nextExcludeSearchExpandedKeys]) =>
251249
preSearchValue !== nextSearchValue && !!(nextSearchValue || nextExcludeSearchExpandedKeys),
252250
);
253251

252+
const syncLoadData = hasLoadDataFn ? loadData : null;
253+
254254
// ========================== Render ==========================
255255
if (memoTreeData.length === 0) {
256256
return (
@@ -292,7 +292,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
292292
showIcon={showTreeIcon}
293293
switcherIcon={switcherIcon}
294294
showLine={treeLine}
295-
loadData={loadDataFun}
295+
loadData={syncLoadData}
296296
motion={treeMotion}
297297
activeKey={activeKey}
298298
// We handle keys by out instead tree self

0 commit comments

Comments
 (0)