Theo's Typesafe Cult

TTC

Theo's Typesafe Cult

Join the community to ask questions about Theo's Typesafe Cult and get answers from other members.

Join

Best way to style range inputs?

I'm trying to style a range input. I can't decide between overriding platform specific styles myself and using the native input tag or using react-range. That 5kb size is concerning me... What would you do?

Store Historic Values

So I'm currently working on a project where I want to display the changes of floor prices of NFT collections in the past 24h, 7days, 1 month. I'm tracking the current floor price in realtime and updates the floor field for that collection. Now I was wondering what the best way would be to store the historic values, since having a field that updates everyday at 0:00 doesn't seem quite like a good solution. Every help is appreciated : )...

is it fine to store the server state in the forked process? (PM2 cluster)

so my server keeps a user session in memory... and I want to introduce clustering using PM2. I obviously want to keep the state global, so I've found this pattern called sidecar pattern, where you use the loopback to share info between processes and I thought who needs Reddis cache while I'm in the same host. so do I just use this pattern and make those instances of the server's process store the state in forked one?...

Are there any differences between these two pieces of code performance or bug wise?

I don't believe they do, but I found the second snippet in my codebase, so I wanted to be sure that I wasn't going to break something that I didn't try. Everything seems fine when I try it myself on my local server and test the functionality of what is being updated, but wanted to know if I was missing something, or some practice, by adding an empty array first
this.setState({ user: { ...(response || {}), ...data } });
this.setState({ user: { ...(response || {}), ...data } });
...

Help - session type in _app.tsx is missing

I recently opened my _app.tsx and noticed that there was an error with the session object being destructured in the app. I'm not too sure what went wrong here, but I did remove and reinstall my node_modules for good measure, and no luck. Repo link - https://github.com/SeanCassiere/next-discord-clone/blob/master/src/pages/_app.tsx#L17...

T3 Stack NextAuth How to get Provider access token

I have one question I have T3 Stack, PrismaAdapter, GithubProvider How can I get access token from Github Provider? ```javascript callbacks: { async session({ session, user, token}) { },...

Simple postgreSQL question (or maybe its generic sql idk)

any postgres gigachads in here? or maybe this is in plain sql too. but what is the different between these two ``` select id, force, name, "equipment_name" from "Exercise"...

Can you (or should you I suppose) put a type inside of a component?

Primarily asking in relation to performance. I know that putting a type inside of a component is something that you can do, but does it give any performance hit to do so? This is more just to put types right on top of functions that reside inside of a component, instead of doing them inline. Example: ```ts const BlahComponent = () => {...

tRPC Query being called client side even with dehydrated state

I have a trpc v10 prefetch in gssp, it's being passed in correctly and hydrated properly, but the query is still being called client side

Typescript behaving strangely when inferring function return type

Today I stumbled across a thing in typescript, where it was inferring the return type of a function with an if statement very strangely Playgroundlink: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABMOcBGBDATgCkwLwC5EwQBbNAUywEpiBvRA40i6xAX0QB9F6v6AKESIA9KJGSRAPQD8wxDGCI8GfDT4KRWSlBBYk9AhwUntu-YZMnBoSLARNsBHCjgtyVWppHipiOQUlFTcNISkdPQM+NzNOBUjLPmsgA Why is ts inferring the return type as {foo?: undefined} when its just {}? When I type the return value explicitly it just does what you would expect it to do......

cron job for sending user a email or notification?

Hello, I m making a scheduling app using t3 stack and I want to send the user an email or maybe push notification (PWA) on the specific interval (user can set interval, in days). But not sure how or with what service this could be done?

Next Future Image Rounded?

Using next/future/image with tailwindcss and can't get an image to round ```ts <div className="flex items-stretch justify-center"> <div className="not-prose relative flex-1">...

Avoid overriding last api response

Hey! I'm developing a react app with an input that makes calls to the google books API while you type. The problem is that sometimes there is a response that takes longer than the last fetch and overrides it. I can solve it by increasing the delay time in the debounce function, but it is ugly that it is updated too late, or by sending abort signals that cancel the previous fetch request, but with this, the grid is not updating with the results while I write, so it doesn't looks good. Is there any other approach I can follow?...

what is the purpose of react protected routes?

shouldn't routes be protected at the server end?

Why does that work? - Runtime Config with Nextjs

(unsure about the tag, so I am just going with both, feel free to correct me on it tho) Could some please explain why this working? I am working with runtime environment variables right now. As noted in the docs of nextjs it says that the page is required to be ssr'ed in order to use the publicRuntimeConfig (https://nextjs.org/docs/api-reference/next.config.js/runtime-configuration) ...

hey I'm planning to use this authentication method on my app.

1) browser sends creds 2) server sends an AES encrypted session, which has the username 3) browser stores it in the local storage 4) the session has a creation date so it can be expired after some time 5) the encrypted session sent with each request with the app not the browser...

What should i use t3-stack or express-trpc-nextjs for this project?

Hi guys, I have a question. I'm building a fullstack app and my first thought was to use t3-stack to do it, because it's so cool. But, the app needs scheduled tasks, wbrtc and very good interaction for realtime chat, so I can't decide whether to go for t3-stack or nextjs-express-trpc-prisma. Anyway, the real question, is there a way to deploy a nextjs project to render or railway and still gain the benefits of a CDN? Since Vercel does not work for my backend due to vercel timeout serverless...

Custom OAuth Popup Window Redirection

I'm building an oauth popup window like google, fb, github etc. I'm able to do the login, but not able to close the window popup once the login is successful. Example: 1. I open the oauth popup from my website : www.abc.com 2. The URL in the OAuth popup is www.random.com...

Optimistic updates not working tRPC useQuery

So I'm currently trying to implement an optimistic data update with tRPC. I'm following the docs. So far if I just do onSetteled it works fine and the data refetches after a second or two. Now I'm trying to implement the onMutate portion, and for some reason my queryClient.getQueryData() returns undefined, even though I'm passing it the same query that I pass invalidateQueries. Any insight on what I might be missing with the syntax?

Call Mutation again on Error?

Hey guys, if my token is expired, I need to refresh it and then call the API again. Whats the best way to do this in react query? I can't find a way to "re-call" the mutation on error. Should I be doing this in axios interceptors?