randoDev
randoDev
TTCTheo's Typesafe Cult
Created by MagerX on 7/8/2023 in #questions
Should I condense my hooks output array?
gotcha yeah I can imagine more than 2 things its better to do just dot
24 replies
TTCTheo's Typesafe Cult
Created by MagerX on 7/8/2023 in #questions
Should I condense my hooks output array?
Maybe "exactly how you use" is strong opinion of mine, would you share why you are opposed to destructuring? I'm guessing possibly more stack space, undefined(but we know the object shape here) variable, and clutter? wondering if there is anything I'm missing
24 replies
TTCTheo's Typesafe Cult
Created by MagerX on 7/8/2023 in #questions
Should I condense my hooks output array?
you can rename them as follows, this is exactly how you use multiple useMutation/Query hooks of ReactQuery
const {sync: userSync, isValid:userIsValid, /* actions */} = useValidation(UserValidation);
const {sync: emailSync, isValid:emailIsValid, /* actions */} = useValidation(EmailValidation);
const {sync: userSync, isValid:userIsValid, /* actions */} = useValidation(UserValidation);
const {sync: emailSync, isValid:emailIsValid, /* actions */} = useValidation(EmailValidation);
I prefer .optional() If you have it in the validator that is not marked optional, then it must be required. This level of implicitness I don't feel like its abstracting much if at all.
24 replies
TTCTheo's Typesafe Cult
Created by MagerX on 7/8/2023 in #questions
Should I condense my hooks output array?
I didn't want to complicate the potential for multiple useValidations in a component
I didn't want to complicate the potential for multiple useValidations in a component
I'm not sure if I follow what you mean. What does having multiple useValidations is a component have to do with it returning an array or an object? I just like object for #props > 2 because I get autocomplete and select what I need on the left side, instead of having to read what it returns and fish out specific index of the thing you are looking for React Query does this too with number of prop it returns name spacing things can also be done with array too you just return object as element
const [first, secObj] = ["first", {a:"a",b:"b"}]
const [first, secObj] = ["first", {a:"a",b:"b"}]
but like I said, why not just object
24 replies
TTCTheo's Typesafe Cult
Created by MagerX on 7/8/2023 in #questions
Should I condense my hooks output array?
or just return an object. I feel better knowing what I'm using when there are more than 2 things
const { syncInput, isPropertyValid } = useValidation(thing);
const { syncInput, isPropertyValid } = useValidation(thing);
24 replies
TTCTheo's Typesafe Cult
Created by Romain on 7/6/2023 in #questions
Zustand or Jotai for a Dashboard app ?
Jotai is simply a global useState that you can probably implement a bad version of it with useState & localStorage go Zustand if you need to group operations with the state itself
8 replies
TTCTheo's Typesafe Cult
Created by King Dice on 7/7/2023 in #questions
question about public and private procedures in trPC
https://www.youtube.com/watch?v=x4mu-jOiA0Q https://www.c-ehrlich.dev/img/youtube/trpc-data-flows.png I'm not really sure as to what the question is, but the comment does not imply user is "executing" the query. I'm guessing you meant context being exposed to client side? Anyhow Once function is invoked from client, as far as I know on the server, new tRPC context gets created. Depending on your middleware ("use" directive on tRPC init things), you can do things to check or add things to the context that you can use later down the "server" pipeline NOTE - client does NOT have access to tRPC ctx, unless you return them as a response of your "procedure" publicProcedure does not have any middleware that checks for auth hence the comment. I don't know if it adds user data I need to check myself later default protectedProcedure (if you are using NextAuth, tRPC, Prisma) basically queries DB to check if user is authed or not and adds session object to the ctx I might be wrong but that's as far as I know for now
3 replies