Global search waits for selection before submitting.

This commit is contained in:
Roland 2024-01-01 15:16:03 -07:00
parent 377c69e8a7
commit 3ad7b8af00
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
9 changed files with 141 additions and 169 deletions

View file

@ -63,7 +63,7 @@ export const useRecurringTimeout = (callback, delay) => {
}, [delay])
}
export const useLatestRequest = (delay = 300) => {
export const useLatestRequest = (delay = 300, defaultLoading = false) => {
// A hook which ignores older requests and will only set `data` to the latest response's data.
// usage: sendRequest(async () => await yourAPICall(...args));
@ -72,7 +72,7 @@ export const useLatestRequest = (delay = 300) => {
const latestRequestRef = React.useRef(0);
const debounceTimerRef = React.useRef(null);
// Loading while awaiting.
const [loading, setLoading] = React.useState(false);
const [loading, setLoading] = React.useState(defaultLoading);
const sendRequest = React.useCallback((fetchFunction) => {
if (debounceTimerRef.current) {