why does the create-post.tsx component need the 'use client' directive in the default project?
I'm a n00b with create-t3 but have used all these technologies in the past (except tRPC). Recently, I've been more focused on DevOps so it's my return trip to the Javascript ecosystem.
I follow Theo's YouTube channel and wasn't sure if it was something he'd mentioned on a video or something I saw in the docs, but the
I'm familiar with difference between client components and server components in React (I was a React dev before I started getting more interested in cloud/devOps).
Forms would be a great use case for server components and I'm just curious why these were pre-written like this? I'm guessing it's something with tRPC? I'm going to start playing with it so will update if I can figure anything out, but if anyone knows the video or the place in the docs I'm talking about, I'd really appreciate it!
I follow Theo's YouTube channel and wasn't sure if it was something he'd mentioned on a video or something I saw in the docs, but the
create-post.tsx
file in the default ct3-app uses the 'use client'
directive and I can't seem to find the explanation anywhere. I know I either saw or heard it and it's driving me nuts.I'm familiar with difference between client components and server components in React (I was a React dev before I started getting more interested in cloud/devOps).
Forms would be a great use case for server components and I'm just curious why these were pre-written like this? I'm guessing it's something with tRPC? I'm going to start playing with it so will update if I can figure anything out, but if anyone knows the video or the place in the docs I'm talking about, I'd really appreciate it!
2 Replies
I didn't find exactly what I was looking for, but I did at least get an answer to this questions. The issue is with React Query as it only runs client-side
the "use client" directive is not related to trpc. generally, all components are server rendered and the "use client " is used when you want to render the file/component on the client side.
hope it helps