CEC-5150: search on fleets in bulk action (#454)

* CEC-5150: search on fleets in bulk action

* add deps

* add deps

* sonar

* sonar

* break out fetch
This commit is contained in:
Tristan Timblin
2023-10-02 13:11:48 -07:00
committed by GitHub
parent 8d867a7a1e
commit f4d45abfca
8 changed files with 127 additions and 64 deletions

View File

@@ -1 +1,2 @@
export { useTimeoutState } from "./useTimeoutState";
export { useUpdateManifest } from "./useUpdateManifest";

View File

@@ -0,0 +1,21 @@
import { useCallback, useState } from "react";
export const useTimeoutState = (defaultState) => {
const [state, _setState] = useState(defaultState);
const [currentTimeoutId, setCurrentTimeoutId] = useState();
const setState = useCallback(
(action, opts) => {
if (currentTimeoutId != null) {
clearTimeout(currentTimeoutId);
}
_setState(action);
const id = setTimeout(() => _setState(defaultState), opts?.timeout);
setCurrentTimeoutId(id);
},
[currentTimeoutId, defaultState]
);
return [state, setState];
};