1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Fix React key missing

This commit is contained in:
xmflsct
2022-12-25 17:40:53 +01:00
parent 21d6baa70d
commit 34f7218c34
8 changed files with 37 additions and 32 deletions

View File

@ -11,6 +11,8 @@ import {
} from '@tanstack/react-query'
import { infinitePageParams } from './utils'
import { PagedResponse } from '@api/helpers'
import { useSelector } from 'react-redux'
import { checkInstanceFeature } from '@utils/slices/instancesSlice'
export type QueryKeyFollowedTags = ['FollowedTags']
const useFollowedTagsQuery = (
@ -21,14 +23,23 @@ const useFollowedTagsQuery = (
>
} | void
) => {
const canFollowTags = useSelector(checkInstanceFeature('follow_tags'))
const queryKey: QueryKeyFollowedTags = ['FollowedTags']
return useInfiniteQuery(
queryKey,
async ({ pageParam }: QueryFunctionContext<QueryKeyFollowedTags>) => {
const params: { [key: string]: string } = { ...pageParam }
return await apiInstance<Mastodon.Tag[]>({ method: 'get', url: `followed_tags`, params })
return await apiInstance<Mastodon.Tag[]>({
method: 'get',
url: `followed_tags`,
params: { limit: 200, ...params }
})
},
{
enabled: canFollowTags,
staleTime: Infinity,
cacheTime: Infinity,
...params?.options,
...infinitePageParams
}