diff --git a/src/BaseSelect.tsx b/src/BaseSelect.tsx index 04ce97d1..337ca2c1 100644 --- a/src/BaseSelect.tsx +++ b/src/BaseSelect.tsx @@ -395,7 +395,7 @@ const BaseSelect = React.forwardRef((props, ref) [tokenSeparators], ); - const { isValidMaxCount, overMaxCount, diff } = useOverMaxCount(); + const { isValidMaxCount, overMaxCount, diff } = useOverMaxCount(multiple); const onInternalSearch = (searchText: string, fromTyping: boolean, isCompositing: boolean) => { if (isValidMaxCount && overMaxCount) { diff --git a/src/OptionList.tsx b/src/OptionList.tsx index 1caca42d..3256e4b0 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -71,7 +71,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, r // =========================== List =========================== const listRef = React.useRef(null); - const { isValidMaxCount, overMaxCount } = useOverMaxCount(); + const { isValidMaxCount, overMaxCount } = useOverMaxCount(multiple); const mergedOverMaxCount = isValidMaxCount && overMaxCount; diff --git a/src/hooks/useOverMaxCount.ts b/src/hooks/useOverMaxCount.ts index 80907afe..b160f682 100644 --- a/src/hooks/useOverMaxCount.ts +++ b/src/hooks/useOverMaxCount.ts @@ -1,10 +1,8 @@ import React from 'react'; -import useBaseProps from './useBaseProps'; import SelectContext from '../SelectContext'; import type { SelectContextProps } from '../SelectContext'; -const useOverMaxCount = () => { - const { multiple } = useBaseProps() || {}; +const useOverMaxCount = (multiple: boolean) => { const { maxCount, rawValues } = React.useContext(SelectContext) || {}; return React.useMemo( () => ({ @@ -12,7 +10,7 @@ const useOverMaxCount = () => { overMaxCount: rawValues?.size >= maxCount, diff: maxCount - rawValues?.size, }), - [maxCount, multiple, rawValues?.size], + [multiple, maxCount, rawValues?.size], ); };