Add debounce hook (#3524)

* Remove noop
* Add debounce hook
This commit is contained in:
DingDongSoLong4
2023-03-13 04:24:37 +02:00
committed by GitHub
parent 798b3e6dd7
commit bc3730d49f
11 changed files with 180 additions and 181 deletions

View File

@@ -10,7 +10,6 @@ import Select, {
OptionsOrGroups,
} from "react-select";
import CreatableSelect from "react-select/creatable";
import debounce from "lodash-es/debounce";
import * as GQL from "src/core/generated-graphql";
import {
@@ -31,6 +30,7 @@ import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import { TagPopover } from "../Tags/TagPopover";
import { defaultMaxOptionsShown, IUIConfig } from "src/core/config";
import { useDebouncedSetState } from "src/hooks/debounce";
export type SelectObject = {
id: string;
@@ -354,9 +354,7 @@ export const GallerySelect: React.FC<ITitledSelect> = (props) => {
value: g.id,
}));
const onInputChange = debounce((input: string) => {
setQuery(input);
}, 500);
const onInputChange = useDebouncedSetState(setQuery, 500);
const onChange = (selectedItems: OnChangeValue<Option, boolean>) => {
const selected = getSelectedItems(selectedItems);
@@ -407,9 +405,7 @@ export const SceneSelect: React.FC<ITitledSelect> = (props) => {
value: s.id,
}));
const onInputChange = debounce((input: string) => {
setQuery(input);
}, 500);
const onInputChange = useDebouncedSetState(setQuery, 500);
const onChange = (selectedItems: OnChangeValue<Option, boolean>) => {
const selected = getSelectedItems(selectedItems);
@@ -459,9 +455,7 @@ export const ImageSelect: React.FC<ITitledSelect> = (props) => {
value: s.id,
}));
const onInputChange = debounce((input: string) => {
setQuery(input);
}, 500);
const onInputChange = useDebouncedSetState(setQuery, 500);
const onChange = (selectedItems: OnChangeValue<Option, boolean>) => {
const selected = getSelectedItems(selectedItems);