From 9a2ef310b2f77937cfe16ddc40408617b4a8513b Mon Sep 17 00:00:00 2001 From: jingzouzou <827088092@qq.com> Date: Fri, 18 Oct 2024 21:28:27 +0800 Subject: [PATCH] chore: add all dependencies to loadDataFun --- src/OptionList.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/OptionList.tsx b/src/OptionList.tsx index e7d89c72..939b1e3d 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -196,15 +196,14 @@ const OptionList: React.ForwardRefRenderFunction = (_, onKeyUp: () => {}, })); - const loadDataFun = React.useMemo(() => { // should not pass `loadData` when expandedKeys is not changed if (!searchValue && searchExpandedKeys?.length && !mergedExpandedKeys) { - return null + return null; } - return searchValue ? null : (loadData as any) - }, [searchValue]) + return searchValue ? null : (loadData as any); + }, [searchValue, searchExpandedKeys?.length, mergedExpandedKeys, loadData]); // ========================== Render ========================== if (memoTreeData.length === 0) {