Josh
Josh
TTCTheo's Typesafe Cult
Created by Josh on 1/23/2024 in #questions
Generic type that extracts component props
Im tring to make a generator function that extracts the props of a component and adds in some extra stuff. The code is pretty straight forward
type ViewProps<T extends JSXElementConstructor<unknown>> = React.ComponentProps<T>
type EmailProps<T extends JSXElementConstructor<any>> = {
to: string
subject: string
props: ViewProps<T>
}

export const emailer = {
send: {
InviteReader: async (props: EmailProps<typeof InviteReader>) => {
await resend?.emails.send({
to: props.to,
subject: props.subject,
html: await render(InviteReader({...props.props}))
})
}
}
}
type ViewProps<T extends JSXElementConstructor<unknown>> = React.ComponentProps<T>
type EmailProps<T extends JSXElementConstructor<any>> = {
to: string
subject: string
props: ViewProps<T>
}

export const emailer = {
send: {
InviteReader: async (props: EmailProps<typeof InviteReader>) => {
await resend?.emails.send({
to: props.to,
subject: props.subject,
html: await render(InviteReader({...props.props}))
})
}
}
}
This works as expected, where props.props is the properties of the InviteReader component. Is there a way i can do this while avoiding the any from EmailProps?
5 replies
TTCTheo's Typesafe Cult
Created by Josh on 5/31/2023 in #questions
What is wrapping a next server action in startTransition doing?
This was brought up in another question. I came up with the following explination, however this is just from reverse engineering it in my head on the fly, so i have no idea if im on the right track or not. if you arent updating the client, you dont need to use startTransition (per docs). Updating the client includes doing any of redirect, revalidatePath, or revalidateTag. If we ARE updating state, and therefore updating the client, this inherently means we are manipulating the client state in some way, since our UI is changing after the server action is complete. In react, we use startTransition to start non-blocking state updates, so in theory, if you use a server action & dont wrap it in startTransition, your UI would completely block untill the server action is done. Since this is not what we want, we tell react to let the client continue to update and move around while the server is processing the request by wrapping it in the startTransition.
1 replies
TTCTheo's Typesafe Cult
Created by Josh on 5/30/2023 in #questions
Need suggestions for better infra CICD
alright, so for this project i use docker containers for everything. my compose file has a redis cache for session management, python container hosting a flask api, frontend served inside an nginx reverse proxy as static pages (with a reverse proxy on the /api route to the flask backend, as well as a reverse proxy for a pgadmin subdomain). RN, on PR acceptance to main, i build all the containers in a gh action, publish them to docker hub in a private repo, then on the fly, convert the docker compose file into a cloud formation template, generate our env variables, create an ecs context, and re-up
89 replies