mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fix: unnecessory data fetch when swithing apps category on explore page (#5155)
This commit is contained in:
parent
c923684edd
commit
e05183c7d2
|
@ -1,4 +1,4 @@
|
||||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
|
import { usePathname, useSearchParams } from 'next/navigation'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
type UseTabSearchParamsOptions = {
|
type UseTabSearchParamsOptions = {
|
||||||
|
@ -24,7 +24,6 @@ export const useTabSearchParams = ({
|
||||||
searchParamName = 'category',
|
searchParamName = 'category',
|
||||||
disableSearchParams = false,
|
disableSearchParams = false,
|
||||||
}: UseTabSearchParamsOptions) => {
|
}: UseTabSearchParamsOptions) => {
|
||||||
const router = useRouter()
|
|
||||||
const pathName = usePathname()
|
const pathName = usePathname()
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const [activeTab, setTab] = useState<string>(
|
const [activeTab, setTab] = useState<string>(
|
||||||
|
@ -37,7 +36,7 @@ export const useTabSearchParams = ({
|
||||||
setTab(newActiveTab)
|
setTab(newActiveTab)
|
||||||
if (disableSearchParams)
|
if (disableSearchParams)
|
||||||
return
|
return
|
||||||
router[routingBehavior](`${pathName}?${searchParamName}=${newActiveTab}`)
|
history[`${routingBehavior}State`](null, '', `${pathName}?${searchParamName}=${newActiveTab}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return [activeTab, setActiveTab] as const
|
return [activeTab, setActiveTab] as const
|
||||||
|
|
Loading…
Reference in New Issue
Block a user