Alaskan donut
Fetch once and never again?
Hey there 👋, I'm wanting to fetch some data
reactionTypes
once when my layout <MainLayout />
renders in Nextjs and never again because this data does not change. Currently, I have placed (what I think is) a headless component into my layout that accesses the query client then sets a staleTime: Infinity
default on this specific query.
Is this a dumb strategy? How might you do this differently?
2 replies
Opinionated help: Where to place data access functions with respect to tRPC router(s)?
Hey there 👋 I'm currently trying to decide where to place my data access functions with respect to my tRPC routers. Currently, I have them placed at
src/data-access/post/mutate-thing.ts
, and I am wanting to move them into a folder structure like this: src/server/routers/post/functions/mutate-thing.ts
but this feels a bit too nested (maybe not a bad thing) and for someone new to my codebase, this might make it difficult to find these functions.
My routers are all obviously defined at src/server/routers
, and I import my data access functions directly into each procedure within each router. Should I leave these data functions where they are at?2 replies
Dynamically generate url for httpBatchLink
Hey there 👋 is it possible to generate a url for httpBatchLink instead of hardcoding one? I attempted the below code, but this doesn't work. Understandably, the fallback value is used for
url
each time the component mounts.
I believe that I wouldn't even need a useEffect if I wasn't using Next, as I could directly grab these values from window.location
, but since I'm using SSR, this code doesn't make it through the SSR pass.
3 replies
How to get pageParam from useInfiniteQuery()?
How would I write a tRPC call equivalent to this traditional
useInfiniteQuery
? My primary concern here is that I need to pass in a cursor to my procedure, and upon each successive query I need to update this cursor for the next call.
Maybe it should be something like this?
2 replies