bakdaddy
bakdaddy
TTCTheo's Typesafe Cult
Created by Cody on 9/25/2024 in #questions
Weird React Behaviour, lost on how to debug
I don't know if you've already figured it out or no (judging from the time you've first posted), but let me know if there's any more things poping up
6 replies
TTCTheo's Typesafe Cult
Created by Cody on 9/25/2024 in #questions
Weird React Behaviour, lost on how to debug
maybe the issue is in the different part of the app that you think
6 replies
TTCTheo's Typesafe Cult
Created by Cody on 9/25/2024 in #questions
Weird React Behaviour, lost on how to debug
hi @Cody , I tried to reproduce your code, and it is weirdly working for me, though I skipped the useForm hook and had my own implementation of Modal element. here's the link to the codesandbox, you can check it out https://codesandbox.io/p/sandbox/g2k8gl
6 replies
TTCTheo's Typesafe Cult
Created by Xteripus on 8/27/2024 in #questions
"Expected an error object to be thrown." At From 0 to Production - The Modern React Tutorial
I'm not really familair with the tutorial (yet) but you could try to pass "as Error" at the end of the line 17
5 replies
TTCTheo's Typesafe Cult
Created by maskmonarch on 7/26/2023 in #questions
React not updating the attribute for an HTML element
i'd suggest moving it to a state and update it using effect ?
25 replies
TTCTheo's Typesafe Cult
Created by maskmonarch on 7/26/2023 in #questions
React not updating the attribute for an HTML element
where's 'useWindowWidth()' from?
25 replies
TTCTheo's Typesafe Cult
Created by EQ on 7/24/2023 in #questions
Prisma Return Type
async findOne<T extends Prisma.UserSelect>(
email: string,
select: T
) {
const user = await this.prisma.user.findUnique({
where: { email: email },
select: { ...select }
});
return user;
}
async findOne<T extends Prisma.UserSelect>(
email: string,
select: T
) {
const user = await this.prisma.user.findUnique({
where: { email: email },
select: { ...select }
});
return user;
}
7 replies
TTCTheo's Typesafe Cult
Created by EQ on 7/24/2023 in #questions
Prisma Return Type
you could just let ts infer return type
7 replies
TTCTheo's Typesafe Cult
Created by EQ on 7/24/2023 in #questions
Prisma Return Type
Do you need an explicit type for return?
7 replies
TTCTheo's Typesafe Cult
Created by bakdaddy on 7/12/2023 in #questions
TS Unchecked Indexed Access
thanks, that's what I kinda thought, just make a new reference and check it
5 replies
TTCTheo's Typesafe Cult
Created by Dylz on 7/14/2023 in #questions
How to make extracting components in typescript less cumbersome?
so something like
type ButtonProps = React.ComponentProps<'button'>

export const Button = ({className, ...props}: ButtonProps) => {
return <button className={`p-2 rounded bg-red ${className}`} {...props}></button>
}
type ButtonProps = React.ComponentProps<'button'>

export const Button = ({className, ...props}: ButtonProps) => {
return <button className={`p-2 rounded bg-red ${className}`} {...props}></button>
}
11 replies
TTCTheo's Typesafe Cult
Created by Dylz on 7/14/2023 in #questions
How to make extracting components in typescript less cumbersome?
and then you could customly choose things like this
const Card = ({ children, className, ...props }: DivProps) => {
return (
<div className={`card shadow-md border ${className}`} {...props}>
{children}
</div>
);
};
const Card = ({ children, className, ...props }: DivProps) => {
return (
<div className={`card shadow-md border ${className}`} {...props}>
{children}
</div>
);
};
11 replies
TTCTheo's Typesafe Cult
Created by Dylz on 7/14/2023 in #questions
How to make extracting components in typescript less cumbersome?
you cound possibly define props like this
//any html element instead of 'div'
type Props = React.ComponentProps<'div'>
//any html element instead of 'div'
type Props = React.ComponentProps<'div'>
just choose an html tag as Element
11 replies
TTCTheo's Typesafe Cult
Created by bakdaddy on 7/12/2023 in #questions
TS Unchecked Indexed Access
bump
5 replies
TTCTheo's Typesafe Cult
Created by gave_one on 7/11/2023 in #questions
I'm trying to override the user object that auth.js session gives you
you could also check for profile
if(account && profile) {
...
}
if(account && profile) {
...
}
7 replies
TTCTheo's Typesafe Cult
Created by gave_one on 7/11/2023 in #questions
I'm trying to override the user object that auth.js session gives you
but for 'accessToken' instead of 'role'
7 replies
TTCTheo's Typesafe Cult
Created by gave_one on 7/11/2023 in #questions
I'm trying to override the user object that auth.js session gives you
7 replies
TTCTheo's Typesafe Cult
Created by gave_one on 7/11/2023 in #questions
I'm trying to override the user object that auth.js session gives you
or
import { DefaultSession } from "next-auth";

declare module "next-auth" {
interface Session {
accessToken?: string;
}
}
import { DefaultSession } from "next-auth";

declare module "next-auth" {
interface Session {
accessToken?: string;
}
}
for having a token on your session object
7 replies
TTCTheo's Typesafe Cult
Created by gave_one on 7/11/2023 in #questions
I'm trying to override the user object that auth.js session gives you
it will make session.user have an optional accessToken prop
7 replies
TTCTheo's Typesafe Cult
Created by gave_one on 7/11/2023 in #questions
I'm trying to override the user object that auth.js session gives you
make a nextauth.d.ts file with something like that
import { DefaultSession, DefaultUser } from "next-auth";

interface IUser extends DefaultUser {
/**
* Role of user
*/
accessToken?: string;
}
declare module "next-auth" {
interface User extends IUser {}
interface Session {
user?: User;
}
}
import { DefaultSession, DefaultUser } from "next-auth";

interface IUser extends DefaultUser {
/**
* Role of user
*/
accessToken?: string;
}
declare module "next-auth" {
interface User extends IUser {}
interface Session {
user?: User;
}
}
7 replies