Loading video...

Video Failed to Load

Go Home

"How can I use server components for data fetching if all my components also need hooks or onClick?" Move the interactive part into a separate component

50,631 views • 1 year ago •via X (Twitter)

10 Comments

Alfredo Lopez's profile picture
Alfredo Lopez1 year ago

FYI, you don’t need a whole component just for the onClick. Client components can also be just functions, so you can import/assign the onClick from a RSC just fine.

Phev's profile picture
Phev1 year ago

While I love the simplicity of data fetching in server components, it is very annoying to make those extra data loader wrapper components for the real (interactive) components. It would be nice if one could have server and client components defined in the same file... (where one is just a simple wrapper to load the data on the server)

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

My mindset reversed with RSC. I mostly feel like server components are the main thing, and the client components are just wrappers of interactivity.

Mubashir's profile picture
Mubashir1 year ago

the best strategy is to move interactive components to separate components and mark them as client components with “use client”. you can still render server components as children of those client components as long as you are not directly importing them into the file that is marked with “use client”.

Alexander's profile picture
Alexander1 year ago

What’s the extension to get that intellisense?

Daniel Dunderfelt's profile picture
Daniel Dunderfelt1 year ago

Or just use react-query 😌

Steve's profile picture
Steve1 year ago

What if the children needs props from their parent?

Víctor's profile picture
Víctor1 year ago

I love your vids!

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

🫡

Summit Avenue Web Solutions's profile picture
Summit Avenue Web Solutions1 year ago

I gotta ask how you’re hiding tailwind classes with little logo boi

Related Videos