feat: reset list for isFetchingFirstPage only

This commit is contained in:
DIYgod
2024-07-18 22:40:40 +08:00
parent 2ff9bbc7ed
commit ed1ff0cfb6
@@ -111,13 +111,15 @@ export const useEntriesByView = ({
// so we memo this previous data to avoid the flicker
const prevEntryIdsRef = useRef(entryIds)
const isFetchingFirstPage = query.isFetching && !query.isFetchingNextPage
useEffect(() => {
if (!query.isFetching) {
if (!isFetchingFirstPage) {
prevEntryIdsRef.current = entryIds
setMergedEntries(entryIds)
onReset?.()
}
}, [query.isFetching])
}, [isFetchingFirstPage])
const [mergedEntries, setMergedEntries] = useState<string[]>([])