Skip to content

Commit

Permalink
Remove lazy load prefetch code and query fetching count check, not ne…
Browse files Browse the repository at this point in the history
…eded
  • Loading branch information
jonkafton committed Jan 15, 2025
1 parent c90f4cc commit e594828
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
17 changes: 5 additions & 12 deletions frontends/api/src/ssr/usePrefetchWarnings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect, useState } from "react"
import type { Query, QueryClient, QueryKey } from "@tanstack/react-query"
import { useIsFetching } from "@tanstack/react-query"
import { useMounted } from "./useMounted"

const logQueries = (...args: [...string[], Query[]]) => {
Expand Down Expand Up @@ -49,7 +48,7 @@ export const usePrefetchWarnings = ({
}) => {
const mounted = useMounted()
const [count, setCount] = useState(0)
const fetchingCount = useIsFetching()
// const fetchingCount = useIsFetching()
const [potentialWarnings, setPotentialWarnings] = useState(true)

useEffect(() => {
Expand All @@ -66,8 +65,9 @@ export const usePrefetchWarnings = ({
() => {
if (
process.env.NODE_ENV === "production" ||
!mounted ||
fetchingCount > 0
!mounted
// ||
// fetchingCount > 0
) {
return
}
Expand Down Expand Up @@ -118,13 +118,6 @@ export const usePrefetchWarnings = ({
// We only want to run this on initial render.
// (Aside: queryClient should be a singleton anyway)
// eslint-disable-next-line react-hooks/exhaustive-deps
[mounted, fetchingCount, count],
[mounted, count],
)
}

const PrefetchWarnings = ({ queryClient }: { queryClient: QueryClient }) => {
usePrefetchWarnings({ queryClient })
return null
}

export default PrefetchWarnings
10 changes: 2 additions & 8 deletions frontends/main/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@ import {
} from "ol-components"
import { Provider as NiceModalProvider } from "@ebay/nice-modal-react"
import ConfiguredPostHogProvider from "@/page-components/ConfiguredPostHogProvider/ConfiguredPostHogProvider"
import { usePrefetchWarnings } from "api/ssr/usePrefetchWarnings"
import { AppProgressBar as ProgressBar } from "next-nprogress-bar"
import type { NProgressOptions } from "next-nprogress-bar"
import dynamic from "next/dynamic"
import { usePrefetchWarnings } from "api/ssr/usePrefetchWarnings"

const PrefetchWarnings = dynamic(() => import("api/ssr/usePrefetchWarnings"), {
ssr: false,
})

const PROGRESS_BAR_OPTS: NProgressOptions = { showSpinner: false }

export default function Providers({ children }: { children: React.ReactNode }) {
const queryClient = getQueryClient()

usePrefetchWarnings()
usePrefetchWarnings({ queryClient })

return (
<>
Expand All @@ -35,7 +30,6 @@ export default function Providers({ children }: { children: React.ReactNode }) {
shallowRouting
/>
<QueryClientProvider client={queryClient}>
<PrefetchWarnings queryClient={queryClient} />
<ConfiguredPostHogProvider>
<NextJsAppRouterCacheProvider>
<ThemeProvider>
Expand Down

0 comments on commit e594828

Please sign in to comment.