Git Product home page Git Product logo

Comments (11)

davidbarratt avatar davidbarratt commented on August 16, 2024

The restriction that Client Components aren't allowed to import Server Components is the source of complexities.

Do you mean import or render?

from rfcs.

davidbarratt avatar davidbarratt commented on August 16, 2024

I think you may be conflating Server-Side Rendering (SSR) and Server Components. The former can render client components, the latter cannot. Either can import client components.

from rfcs.

brillout avatar brillout commented on August 16, 2024

@davidbarratt

Have look at https://github.com/josephsavona/rfcs/blob/server-components/text/0000-server-components.md#capabilities--constraints-of-server-and-client-components

Client Components [...] may not import Server Components

from rfcs.

davidbarratt avatar davidbarratt commented on August 16, 2024

@davidbarratt
Have look at https://github.com/josephsavona/rfcs/blob/server-components/text/0000-server-components.md#capabilities--constraints-of-server-and-client-components

Oh right, I'm sorry I read what you wrote backwards. Yes the RFC makes sense to me. A client component couldn't import a server compoment because a server component could import Node's fs module (as an example). If that is the case, then how would you expect the client to handle that import?

from rfcs.

brillout avatar brillout commented on August 16, 2024

Let me elaborate with what I mean with:

  • The webpack react plugin removes the server component source code from the client-side bundle.

Concretely the webpack react plugin would replace the entire source code of a Server Component with the client-side mechanism that calls the /_react/render endpoint. (More precisely with a call to that mechanism with as argument the ID of the Server Component.)

from rfcs.

davidbarratt avatar davidbarratt commented on August 16, 2024

Isn't that what shared components are? Basically the io libraries have both a server-side and client-side mechanism within them.

from rfcs.

josephsavona avatar josephsavona commented on August 16, 2024

@brillout Thanks for taking the time to share your thoughts. I’d like to reply, but we’d like to keep the discussion about Server Components focused in a single place. Could you please move this post to a comment on the main RFC? That way people can find the answer more easily wo following two separate threads. Thanks!

from rfcs.

brillout avatar brillout commented on August 16, 2024

@josephsavona done. I'm super looking forward to read your reply!

from rfcs.

brillout avatar brillout commented on August 16, 2024

@davidbarratt

A central piece of the proposal is

Once the virtual dom computing goes server-side it never goes back client-side.

For that, the server should be able to compute the virtual dom of all components, including the Client Components. The current design prohibits Client Components from running/rendering in the server.

Shared Components are not the solution either as they are prohabited to have state and side-effects.

from rfcs.

davidbarratt avatar davidbarratt commented on August 16, 2024

For that, the server should be able to compute the virtual dom of all components, including the Client Components. The current design prohibits Client Components from running/rendering in the server.

That is Server Side Rendering (SSR). If the client has already loaded the application, why would it need to render on the server? That wouldn't be effecient.

Shared Components are not the solution either as they are prohabited to have state and side-effects.

Right because you can't have state nor side-effects on the server...

from rfcs.

gaearon avatar gaearon commented on August 16, 2024

Responded in #188 (comment)

from rfcs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.