Loading video...

Video Failed to Load

Go Home

"How to share state between React client components with a parent server component?" 👇

51,557 views • 1 year ago •via X (Twitter)

9 Comments

지후's profile picture
지후1 year ago

Although it’s quite obvious, you did not add count-provider code

chuckstock's profile picture
chuckstock1 year ago

is there a reason for using `use` instead of `useContext`?

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

nope, same result

Kevin Nguyen's profile picture
Kevin Nguyen1 year ago

This vs. Zustand what is your take?

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

Depends on the type of the app. If it's an interaction-heavy app with a lot of state sharing -> client state lib, if not, context provider here and there is fine

Qing | quotion.co's profile picture
Qing | quotion.co1 year ago

This looks obvious, but what about sharing state between server and client components? I’m using queryparams, not ideal tbh

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

Why not ideal?

Carlos Terrazas's profile picture
Carlos Terrazas1 year ago

wouldn't it be better to zustand in each client component and thus avoid adding code in the server component? or is it just the demo with contextApi?

Alex Aaron Peña's profile picture
Alex Aaron Peña1 year ago

if the context is defined server side, doesn’t this imply the single context is shared across all users visiting the web app? as I understand if I define a zustand datastore, wrap it in a provider, mount it on a server component, all users will share the same store

Related Videos