Skip to content

Commit 708c0c4

Browse files
committed
fix: handleOnSearch not undefined
1 parent 7827c70 commit 708c0c4

File tree

1 file changed

+3
-20
lines changed
  • superset-frontend/packages/superset-ui-core/src/components/Select

1 file changed

+3
-20
lines changed

superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
ClipboardEvent,
2828
Ref,
2929
ReactElement,
30-
useRef,
3130
} from 'react';
3231

3332
import { ensureIsArray, t, usePrevious } from '@superset-ui/core';
@@ -137,8 +136,6 @@ const Select = forwardRef(
137136
);
138137
const [onChangeCount, setOnChangeCount] = useState(0);
139138
const previousChangeCount = usePrevious(onChangeCount, 0);
140-
const cancelRef = useRef<(() => void) | null>(null);
141-
const isMounted = useRef(true);
142139
const fireOnChange = useCallback(
143140
() => setOnChangeCount(onChangeCount + 1),
144141
[onChangeCount],
@@ -403,26 +400,12 @@ const Select = forwardRef(
403400
onSearch?.(searchValue);
404401
}, Constants.FAST_DEBOUNCE);
405402

406-
useEffect(
407-
() => () => {
408-
isMounted.current = false;
409-
},
410-
[],
411-
);
412-
413403
useEffect(() => {
414-
cancelRef.current = handleOnSearch.cancel;
404+
if (handleOnSearch !== undefined) {
405+
handleOnSearch.cancel();
406+
}
415407
}, [handleOnSearch]);
416408

417-
useEffect(
418-
() => () => {
419-
if (!isMounted.current) {
420-
cancelRef.current?.();
421-
}
422-
},
423-
[],
424-
);
425-
426409
const handleOnDropdownVisibleChange = (isDropdownVisible: boolean) => {
427410
setIsDropdownVisible(isDropdownVisible);
428411

0 commit comments

Comments
 (0)