You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detect components inside client component trees that does not rely on any props that should make them client compoennts and convert them to server components.
Background
I find myself composing client components and pass them rsc nodes from the outside.
I can keep doing it, but I think it's relatively simple to detect which nodes are independent inside the client component trees, and handle those as if they are pure rsc compoennts.
Proposal
I think theoretically the right way to go is to go over each client component tree, while rendering in the serverside, and do this:
Detect possible server components >> If the component's props did not come from a dynamic place, e.g, component has no props like an icon component or something, or the props came from the server alone, not depending on hooks or state or something like that.
Mark & Render those components and cache them by their - Component filename & given props
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Detect components inside client component trees that does not rely on any props that should make them client compoennts and convert them to server components.
Background
I find myself composing client components and pass them rsc nodes from the outside.
I can keep doing it, but I think it's relatively simple to detect which nodes are independent inside the client component trees, and handle those as if they are pure rsc compoennts.
Proposal
I think theoretically the right way to go is to go over each client component tree, while rendering in the serverside, and do this:
Please let me know what you think
Beta Was this translation helpful? Give feedback.
All reactions