Added initial loading setting

Enabled pushing to history on filter setting
This commit is contained in:
2023-07-27 12:00:22 +03:00
parent 9b4ef41030
commit abe3e64883
4 changed files with 11 additions and 10 deletions

View File

@ -19,16 +19,16 @@ type UseFetchErrored<T> = {
data: undefined
} & UseFetchShared<T>
const gotError = <T>(res: UseFetchErrored<T> | UseFetchSucced<T>): res is UseFetchErrored<T> => (
type UseFetchReturn<T> = UseFetchSucced<T> | UseFetchErrored<T>
const gotError = <T>(res: UseFetchReturn<T>): res is UseFetchErrored<T> => (
typeof res.error === 'string'
)
const fallbackError = <T>(res: UseFetchSucced<T> | UseFetchErrored<T>) => (
const fallbackError = <T>(res: UseFetchReturn<T>) => (
gotError(res) ? res.error : res.data
)
type UseFetchReturn<T> = UseFetchSucced<T> | UseFetchErrored<T>
function useFetch<R, T>(
url: string,
method: RequestInit['method'],
@ -40,7 +40,7 @@ function useFetch<R, T>(
): UseFetchReturn<T> {
const [data, setData] = useState(initialData)
const { doSend, loading, error } = useSend(url, method, needAuth, guardResponse, processResponse, params)
const { doSend, loading, error } = useSend(url, method, needAuth, guardResponse, processResponse, true, params)
useEffect(() => {
doSend().then(