File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 33import { useQuery } from "@tanstack/react-query" ;
44import { Globe } from "lucide-react" ;
55import Image from "next/image" ;
6- import { useEffect , useState } from "react" ;
6+ import { useState } from "react" ;
77import { Skeleton } from "@/components/ui/skeleton" ;
88import { useTRPC } from "@/lib/trpc/client" ;
99import { cn } from "@/lib/utils" ;
@@ -18,26 +18,24 @@ export function Favicon({
1818 className ?: string ;
1919} ) {
2020 const trpc = useTRPC ( ) ;
21- const [ isHydrated , setIsHydrated ] = useState ( false ) ;
2221 const [ failedUrl , setFailedUrl ] = useState < string | null > ( null ) ;
2322
24- useEffect ( ( ) => {
25- setIsHydrated ( true ) ;
26- } , [ ] ) ;
27-
23+ // No need to wait for hydration - if the data was prefetched on the server,
24+ // it will be available immediately via the dehydrated state
2825 const { data, isPending } = useQuery (
2926 trpc . domain . favicon . queryOptions (
3027 { domain } ,
3128 {
32- enabled : isHydrated ,
29+ // Keep previous data while refetching to prevent flicker
3330 placeholderData : ( prev ) => prev ,
3431 } ,
3532 ) ,
3633 ) ;
3734
3835 const url = data ?. url ?? null ;
3936
40- if ( ! isHydrated || isPending ) {
37+ // Show skeleton only when truly pending (not when hydrating with prefetched data)
38+ if ( isPending ) {
4139 return (
4240 < Skeleton
4341 className = { cn ( "bg-input" , className ) }
You can’t perform that action at this time.
0 commit comments