isaac_way
isaac_way
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Pavel Filo on 12/4/2023 in #questions
When to refetch query after mutation?
the main advantage of refetch is that it’s less error prone and there’s a higher probability your cache matches the server. it’s easier to just refetch than manually update the cache update locally and not refetch has the advantage of not taxing your server if you’re confident the cache is gonna be what it should be there’s no best approach in general for this, you should do what you think makes sense for your use case
5 replies
TTCTheo's Typesafe Cult
Created by Christian Lind on 1/18/2023 in #questions
inferring types from tRPC array
🫡
11 replies
TTCTheo's Typesafe Cult
Created by isaac_way on 5/6/2023 in #questions
"PrismaClient is unable to be run in the browser" in Next.js API route
agreed
9 replies
TTCTheo's Typesafe Cult
Created by kevinka on 5/6/2023 in #questions
Cant use the same router to create multiple createTRPCReact?
you should be able to use it multiple times - probably mismatching package versions somewhere one fix is to go through all of the package.json, set them to use the same versions of trpc @trpc/react-query: ^10.21.0 => @trpc/react-query: 10.21.0 then delete all node modules and reinstall them
3 replies
TTCTheo's Typesafe Cult
Created by isaac_way on 5/6/2023 in #questions
"PrismaClient is unable to be run in the browser" in Next.js API route
i am not connecting to a DB in my browser at all lol that's why this error is weird
9 replies
TTCTheo's Typesafe Cult
Created by isaac_way on 5/6/2023 in #questions
"PrismaClient is unable to be run in the browser" in Next.js API route
i did this and it fixed it
export const prisma = (() => {
if (typeof window !== "undefined") {
return {} as unknown as PrismaClient;
}
return (
globalForPrisma.prisma ??
new PrismaClient({
log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
})
);
})();
export const prisma = (() => {
if (typeof window !== "undefined") {
return {} as unknown as PrismaClient;
}
return (
globalForPrisma.prisma ??
new PrismaClient({
log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
})
);
})();
🤷
9 replies
TTCTheo's Typesafe Cult
Created by Liam Idrovo on 4/28/2023 in #questions
How does a React component require data to render in a SPA
function Page() {
const query = useQuery(async ()=>fetchData());

if(!query.data) return <LoadingSpinner/>;

return (
<Child data={query.data} />
)
}
function Page() {
const query = useQuery(async ()=>fetchData());

if(!query.data) return <LoadingSpinner/>;

return (
<Child data={query.data} />
)
}
not the best way to do it but this is an example component that renders only after the data is fetched
4 replies
TTCTheo's Typesafe Cult
Created by josh-dev627 on 4/17/2023 in #questions
How to handle invalidate queries
Yep!
25 replies
TTCTheo's Typesafe Cult
Created by josh-dev627 on 4/17/2023 in #questions
How to handle invalidate queries
if you do “query.refetch()” it’ll throw out the old data and send it back into a loading state as well just another option.. that’s normally what I do if I want to go back into a loading state
25 replies
TTCTheo's Typesafe Cult
Created by shikishikichangchang on 4/13/2023 in #questions
React query and image gallery ui
given the constraints that: 1. you're rendering the most recent images first 2. you're rendering new images as they load there's no way to avoid the janky rerender. Going to have to either not render the most recent images first or stop rerendering them as they load. IDK of a UI on any web app that automatically renders the most recent results at the top of a list in real time without user input. One thing you can do is what Twitter does. When more recent results are available, twitter adds a "Load X Newer Tweets" button to the top of the list, so it only renders that new stuff when the user actually presses that. This avoids rerendering while they're scrolling them while giving them an option to the see newest stuff
4 replies
TTCTheo's Typesafe Cult
Created by Amit on 4/10/2023 in #questions
trpc alternatives like zodios, ts-rest
trpc-openapi is in fact stable for creating rest endpoints. IMO it's best in cases where you only need to expose a few endpoints via rest, where most of them are only consumed via trpc clients. If all or most of your endpoints need to be exposed via rest, something like zodios might make more sense b/c you're getting the rest endpoints out of the box
4 replies
TTCTheo's Typesafe Cult
Created by packofm&ms on 4/9/2023 in #questions
Trying to implement infinite scroll with infinite query
nextCursor should just be a parameter that your server returns that lets it know where the next page should start whenever it gets passed back to the server. IE if the first page returns the first 10 items, nextCursor could be set to the ID of the 10th tweet, and when the server receives that ID back from the front end it should query starting at that ID. So one of those two things must be going wrong I briefly looked at his code, couldn't tell what was wrong at first glance
3 replies
TTCTheo's Typesafe Cult
Created by cajayethecreator on 4/8/2023 in #questions
TRPC Internal Server Error
Did you make sure your middleware matcher is configured correctly
7 replies
TTCTheo's Typesafe Cult
Created by Jaaneek on 4/5/2023 in #questions
My project got pretty slow
there are probably certain rules that are causing the slowdown, if you can identify and disable those that could fix it... probably some rules related to typescript
39 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
Yeah have to type useNavigation… one nice thing to do is create a reusable hook that has it typed already
function useAppNavigation() {
return useNavigation<StackNavigationProp<ParamList>>();
}
function useAppNavigation() {
return useNavigation<StackNavigationProp<ParamList>>();
}
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
yeah they should update the docs lol
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
Yeah you can use it if you want but I’d recommend useNavigation because it’s easier and you don’t have to prop drill. It works the same you just don’t have to pass or receive the prop
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
React native apps are conceptually a lot closer to an SPA so it’s useful to think of them that way. You do not need to pass the navigate prop ever, you should use the useNavigation() hook to access the navigation prop. Also, I do not recommend rerouting with the navigation prop whatsoever (for things like routing users to the auth screens if they’re not logged in etc). Not 100% sure that’s what you meant though. React navigation has a unique feature where you can navigate via conditionally rendering screens in the navigator, and it simplifies conditional navigation. See https://reactnavigation.org/docs/auth-flow/ , it’s quite nice to use. For most navigation you’ll want to do navigation.navigate though
12 replies