don't reset parts manually, do it all at once

This commit is contained in:
austinried
2022-03-18 14:20:57 +09:00
parent 98ef0d1d44
commit 47c65ea8cb
7 changed files with 27 additions and 30 deletions

View File

@@ -28,7 +28,7 @@ export const useFetchList = <T>(fetchList: () => Promise<T[]>) => {
return { list, refreshing, refresh, reset }
}
export const useFetchList2 = (fetchList: () => Promise<void>, resetList: () => void) => {
export const useFetchList2 = (fetchList: () => Promise<void>) => {
const [refreshing, setRefreshing] = useState(false)
const refresh = useCallback(async () => {
@@ -39,9 +39,8 @@ export const useFetchList2 = (fetchList: () => Promise<void>, resetList: () => v
useActiveServerRefresh(
useCallback(async () => {
resetList()
await refresh()
}, [refresh, resetList]),
}, [refresh]),
)
return { refreshing, refresh }
@@ -72,8 +71,8 @@ export const useFetchPaginatedList = <T>(
useActiveServerRefresh(
useCallback(() => {
reset()
}, [reset]),
refresh()
}, [refresh]),
)
const fetchNextPage = useCallback(() => {