fix: integrate useResource hook in App component and update queryKey in useResource
This commit is contained in:
@@ -7,6 +7,7 @@ import { Outlet, useNavigate } from 'react-router-dom'
|
||||
import { useRegisterSW } from 'virtual:pwa-register/react'
|
||||
import { registerCapacitorListeners } from './CapacitorListener'
|
||||
import { UserContext } from './contexts/UserContext'
|
||||
import { useResource } from './queries/ResourceQueries'
|
||||
import { AuthenticationProvider } from './service/AuthenticationService'
|
||||
import { ErrorProvider } from './service/ErrorProvider'
|
||||
import { GetUserProfile } from './utils/Fetcher'
|
||||
@@ -23,6 +24,7 @@ const remove = className => {
|
||||
const intervalMS = 5 * 60 * 1000 // 5 minutes
|
||||
|
||||
function App() {
|
||||
const resource = useResource()
|
||||
const navigate = useNavigate()
|
||||
startApiManager(navigate)
|
||||
startOpenReplay()
|
||||
|
||||
@@ -3,11 +3,12 @@ import { GetResource } from '../utils/Fetcher'
|
||||
|
||||
export const useResource = () => {
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ['resource'],
|
||||
queryKey: [],
|
||||
queryFn: async () => {
|
||||
const response = await GetResource()
|
||||
return response
|
||||
},
|
||||
staleTime: 6 * 60 * 60 * 1000, // 6 hours in milliseconds
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user