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

Closed modal keeps fetching

Alright this is a problem that I feel like I solved before, I have solved now, but my solution bothers me. Currently, I have a page that has 4 modals, out of those, 2 of them are supposed to fetch data right after they open, but here's the problem: they fetch all the time as long as I'm in that page. The obvious solution is to wrap the modal into a conditional render in the page that holds it, not allowing the modal to exist before isModalVisible == true....

How is option value string even after accepting a ``value={prop}`` of a number type?

Argument of type 'string' is not assignable to parameter of type 'SetStateAction<number>' Meanwhile I type setCurrentPage: (page: number) => void because the only thing i want it to accept must only be numbers ```<select name="num" onChange={(e) => setPerPage(e.target.value)}> {select.map((prop, index) =>{ return(...

will an empty input field override the current database value

if any of the input is empty will it override the current value in the database?

Prevent possibly undefined user with useQuery

I have a hook useUser that looks basically like this
return useQuery(// fetch user)
return useQuery(// fetch user)
Lets imagine that its used in a Layout so when the user is loading the whole app is just a loading spinner. Now I want to get the user inside a component nested in Layout...

Authentication flow

I'm currently working on building a marketplace. So far, everything is working fine with next-auth. I want two roles: customer and provider. I am trying to figure out a way to force registration for one of them, but not quite sure how. Right now, the only way I see it, is that I check the roles on each page and if they are neither customer or provider, then redirect to a page that makes them select one of them so I can assign it to their entry in the db, and then I will be able to show each page correspondingly to their role. I was wondering if there is a better option of forcing it, for example: Click sign up -> Are you customer or provider -> whichever they choose they get to a page of Oauth sign in options and somehow I can save the fact what they chose in the previous setup and automatically fetch it in events: {createUser()} in [...nextauth].ts if possible, this would be the ideal way. Can someone please chime in if they have any ideas on a smooth way to force a role on sign up? Thanks!...

S3 Acl Settings

Hi guys currently we have one bucket with all our files now we are trying to add acl settings so that specific files are privat or public. I am not sure right now if I should create 2 folder in our bucket one for private files and one for public files which the specific acl setting for the folder or if I should just update the acl settings for each file inside the bucket itself (no public, privat folder). Any pros and cons you can think of?...

NextJS api authentication with 3rd party API

Hello ! We currently have a NextJS app that uses its API routes to call an external API and retrieve data that way. So essentially such files might look like this. ```ts import env from "@env/server.mjs"; import axios from "axios"; import { NextApiRequest, NextApiResponse } from "next";...

Central Rest API Vs Direct Database Connection For Data Queries

Hey I am working on a public bot with a dashboard for Minecraft servers and I have made a simple diagram for the architecture of the system. I am wondering if allowing all three services connection to the database is a bad idea or should I have a central api that you query data from.

white screen when changing page

hey guys, im curious and a bit annoy by this, anyone know whats up with this. already turn ssr in trpc but still the same. Any help is greatly appreciated, thanks....

tailwind dashboard current state

hey guys im currently making school project with tailwindUI and i use their dashboard, the problem is when i changes pages the current doesnt changes any idea how?

global react query config for trpc

Hi everyone, I keep having to add
{ refetchOnWindowFocus: false }
{ refetchOnWindowFocus: false }
to all my client queries... I can't seem to find a way to disable it globally in tRPC... Can someone please point me in the right direction of where the global queryClient config options are? Thanks.

using useSession hook

is it good to call useSession many times or make useSession globally, im still kinda new so need a lot of advice and guidance thanksss

Best Practice - Handling undefined deps on custom use hook

Good day everyone! I know this is more of a react specific question, but I spend all day in Nextjs land so I thought I'd pose this question to you all. Been struggling a bit with something. What is everyone's favorite way to handle undefined deps for a useHook? ``` const useSomething = (someDep: string) => { ... something that requires "someDep" ......

Number as env var does not work

I have an .env var set like this PUSH_INVITE_DELAY_MINUTES=0 In my code I am calling it like this ```ts...

is it bad to write to database in .query()

I do get confused sometimes i write my ctx.prisma.user.create({...}) In a .query() Instead of .mutation()...

Tool to hunt down Memory Leaks

Is there a tool out there anyone recommend to hunt down memory leaks? Nextjs crashing after some time (less memory = faster crash) and I can’t figure out where the culprit is. T3-turbo stack project

How difficult is it to port a t3 app to t3-turbo React Native?

Building a new app that might end up on mobile and trying to gauge if it makes sense to learn t3-turbo React Native now and start there or just build it quick with t3 and then worry about mobile apps later.

Next 13 Equivalent of _app.js?

Would the replacement for ./pages/_app.js just be layout.js?

Resize window for Stage Manager in MacOS

I really like the way Stage Manager works when I'm coding, being able to have the little preview to the side and organize different sets of windows really fits my workflow but I haven't found a solid way to get the windows to the correct size (like in the picture). I'm currently using Magnet so snap to the side 50% and then manually dragging. Has anyone found a better solution for this?