jalen21
jalen21
Explore posts from servers
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
BTW, what's the core difference ( your implementation from mine )
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
@Gary, el Pingüino Artefacto Then, I use this on pages ( HydrationBoundary )
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
I think I should have used HydartionBoundary to benefit this approach, in which I'm not using currently
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
"use client";

import React, { useState } from "react";
import { defaultShouldDehydrateQuery, QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";





const ReactQueryDevtoolsProduction = React.lazy(() =>
import("@tanstack/react-query-devtools/build/modern/production.js").then(
(d) => ({
default: d.ReactQueryDevtools,
})
)
)

export default function Providers({ children }: { children: React.ReactNode }) {
const [showDevtools, setShowDevtools] = React.useState(false)

React.useEffect(() => {
// @ts-expect-error
window.toggleDevtools = () => setShowDevtools((old) => !old)
}, [])

const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
// With SSR, we usually want to set some default staleTime
// above 0 to avoid refetching immediately on the client
// staleTime: 0,
// refetchInterval: 24 * 60 * 60 * 1000,
},
dehydrate: {
// per default, only successful Queries are included,
// this includes pending Queries as well
shouldDehydrateQuery: (query) =>
defaultShouldDehydrateQuery(query) ||
query.state.status === "pending",
},
},
})
)

return (
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
{showDevtools && (
<React.Suspense fallback={null}>
<ReactQueryDevtoolsProduction />
</React.Suspense>
)}
{children}
</QueryClientProvider>
)
}
"use client";

import React, { useState } from "react";
import { defaultShouldDehydrateQuery, QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";





const ReactQueryDevtoolsProduction = React.lazy(() =>
import("@tanstack/react-query-devtools/build/modern/production.js").then(
(d) => ({
default: d.ReactQueryDevtools,
})
)
)

export default function Providers({ children }: { children: React.ReactNode }) {
const [showDevtools, setShowDevtools] = React.useState(false)

React.useEffect(() => {
// @ts-expect-error
window.toggleDevtools = () => setShowDevtools((old) => !old)
}, [])

const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
// With SSR, we usually want to set some default staleTime
// above 0 to avoid refetching immediately on the client
// staleTime: 0,
// refetchInterval: 24 * 60 * 60 * 1000,
},
dehydrate: {
// per default, only successful Queries are included,
// this includes pending Queries as well
shouldDehydrateQuery: (query) =>
defaultShouldDehydrateQuery(query) ||
query.state.status === "pending",
},
},
})
)

return (
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
{showDevtools && (
<React.Suspense fallback={null}>
<ReactQueryDevtoolsProduction />
</React.Suspense>
)}
{children}
</QueryClientProvider>
)
}
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
This is what my provider looks like
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
Hmm, I don't understand
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
yeah, I know
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
But If I don't use the prefetch + hydrate, it will not be RSC payload, right ?
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
great, thanks
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
Oh so the payload is RSC like
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
@Gary, el Pingüino Artefacto Here is what I know so far: - if I used the server component to fetch data it will send html so the network tab ( browser ) doesn't show the data structure, it will be RSC payload - But when I used the tanstack query to fetch data, on the network tab, the payload is showing the data structure on the response Am I correct ?
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
oh but If I used the initial data approach, it will send the html, right?
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
Does the prefetch streaming approach send html to browser or the data it self?
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
@Gary, el Pingüino Artefacto Okay, so I have to use the hydration boundary on every page ?
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
in which the queryClient is a custom hook for data fetching
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
@Gary, el Pingüino Artefacto Is initialData good approach? fetch initially on server component and pass it to client component, then inside the client component pass the initialData to queryClient ?
35 replies
TTCTheo's Typesafe Cult
Created by jalen21 on 10/25/2024 in #questions
Can I combo Tanstack query and Server component on Nextjs?
@Gary, el Pingüino Artefacto Do you have example repo please?
35 replies
KPCKevin Powell - Community
Created by jalen21 on 3/16/2024 in #front-end
How can I add truncate like ... if there is overflow in the <g></g> element
Yes it is, I'm using d3 library with createSVG()
4 replies