-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: React Server Module Conventions v2 #227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed a few small typos/carryovers from the previous iteration of the RFC
fix file import in rfc example
Co-authored-by: Matt Hamlin <[email protected]>
Co-authored-by: Matt Hamlin <[email protected]>
Co-authored-by: Matt Hamlin <[email protected]>
Thank you! |
This is confusing. Isn’t it effectively a «use server» directive? Rather than telling the server to use a client component, the perspective would be to denote a client component for use on the server. The result is the same. But when looking at a client component it makes sense that it is the point of focus (not the server). |
ah, I see that my confusion was merely with the wording of the aforementioned paragraph. Since:
So the «use client» directive is only for the server for the purpose of passing the component reference to the client where the component is executed. So «use client» kinda makes sense then. |
You mentioned this in the other thread, but - in my experience - in those scenarios either the project is all one environment or a folder separates the different environments allowing Webpack to bundle each file differently. For example:
I know you're correct that the folders don't matter to Webpack - it just follows the trail of modules. That being said, this i think this structuring happens a lot and it happens for good reasons. |
Instead of |
Following up on my comments from the previous thread:
Great work getting this pushed through! |
…dule-conventions.md
We're going to go ahead with this. Very thankful to everyone for the discussion on the original issue. |
The problem is that now i usually creating my components with .client.tsx or .server.tsx because I need a ez way of difference them. Maybe this not need to be a core feature of React, but the "use client" is a little annoying. Have to be a better way. But after all is a amazing work 20/10. |
I am agreed that "use client" quite annoying.. this open out flexibility that I can decide use same components to render under client or server side without WET. |
No, you won't need to write everything twice. Components are treated as Shared Components by default. From the referenced documentation:
|
Could a compiler automatically do this without needing a |
The key is that when you move it, the props have to be serializable. This doesn't just mean that they use only the subset of types that are supported but also that those props aren't going to be an explosion in data transfer. There's benefit sometimes to move something to the client to make it a reusable template. Dev tooling will highlight this more. It's also important that you teach patterns around what goes where for predictability. I think some kind of "auto-fix" would be nicer to start. That yea, it's totally possible. In fact, this idea spawned from work on Prepack to do exactly that. It just didn't work well for existing code that wasn't written with this code flow in mind. |
- adding use-client allow us to add hooks on server side components - adding use-client based on reactjs/rfcs#227
- adding use-client allow us to add hooks on server side components - adding use-client based on reactjs/rfcs#227 - updated readme to include example on adding nextjs 13 with app folder
Hi team! Really wanted to thank you for the new proposal from file extension to the I think that the name My initial though (wrong one) of RSC was that they would render on the server and the hydrate/render would load it and put in the right place of the React application. But then after looking on the initial demo I noticed that it make use of a Protocol defined to serialize a component. A different name could help preparing everyone for a different mental model of the current standard React components:
The reason to use Again, thank you for the huge work! RSC is really exciting technology! |
But researching more, it seems that the community is more lean toward Server and Client components anyway where other frameworks also use Server/Client separation and introducing a new name might bring even more confusion to everyone. |
I like the idea of simply adding "use client" to a file, but currently bundlers seem to strip away the "use client" directive automatically, causing issues in monorepos like mentioned here: nrwl/nx#13194 If someone has an idea on how to work around this, please point me in the right direction. Thanks for all the hard work put into this! |
I messaged an Nx maintainer so they might be able to get a look at this. |
Yeah. The names aren't perfect (sometimes "Data Components" vs "Interactive Components" seems to make more sense) but in practice I think they have stuck. |
Hey, @jamiter a fix is released in Nx |
React libraries are starting to add
I feel it would be a really good practice from your side, to ensure the ecosystem can handle |
Hope this is the right place to leave feedback. In Jest repo few users reported an issue related with the Seems like users must pass How do you think, would it make sense to add If an extra export condition is not a good idea, I think it would be useful to document that |
@mrazauskas It wouldn't be correct to add it to Basically Configuring |
Ah right.. I didn't take into account SSR. By the way, one user came to an idea (jestjs/jest#13967 (comment)) to use manual mock: // __mocks__/server-only.js
module.exports = {}; In this case all checks of |
The issue is that |
Hello, I hope this the right place for this question. I have a React component library that uses Relay for data fetching for the components. I am trying to accommodate RSCs by preloading data based on this pattern. Is it sensible for libraries other than |
Is there a way to specify in the same file which components are "client" and which are "server"? To use my libraries I use microbundle and it puts everything in the same file, I like microbundle but as a library maintainer should I change the bundler to create it in different files or is there a better way to do it? 🤔 Thanks |
Note: This condition can only be used for conditional `imports` within the project itself. | ||
|
||
Possible addition: A possible addition to this can be to also support the `"server-only"` condition as a less React specific alternative that could be adopted by other frameworks that also choose this strategy. | ||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This is a new take on the original v1 of this proposal. See the discussion there for deeper context on the reason for the changes made.
Please watch the React Server Components intro talk and high level React Server Components RFC for some background context on this RFC.
View the rendered text