-
Notifications
You must be signed in to change notification settings - Fork 665
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
docs: explain better the distinction between islands and components #2369
Comments
I don think is confusing, from the docs: https://fresh.deno.dev/docs/concepts/islands
You mentioned
Thats what islands are, thats what the docs says "components that are rendered on the server and then hydrated on the client." And for
Why would not? buttons can be used to trigger forms by using props, or actions by onClick event, for the second will always be necessary to be an island or be used inside and island |
I think based on the fact that multiple people are confused (who presumably took the time to try to understand, since they took the time to give feedback), that by definition it is confusing. I think the concept that needs to be fleshed out is that the children of islands are still "within" the island. Or, put differently, a distinction should be made between the island "entry-point" and the components which are part of the island. However, I am not a maintainer, so I won't make the call myself. It's also possible the change should be folded into the broader re-org of the Getting Started section (#1632 ) |
I guess u are right 🤔 |
ComponentA function that starts with an uppercase letter that can use hooks and optionally return JSX. Doesn't say anything about where it runs. IslandA form of component that is bundled and executed it in the browser, looks the exact same as a normal component. The only difference is that they're put in special files like Server ComponentA form of component that's only run on the server. Looks the exact same as a normal component, only difference is where it's used. For Fresh means that if you only ever use this component in a route, then it will only run on the server. |
Just as an anecdote, I did find this somewhat confusing at first, especially because I copied the Button island into a component in my Fresh project, and then was confused why it was constantly disabled. Of course, now this makes sense to me. But then when I look at the interactive islands documentation now, looking at the following example:
It's now clear to me that the button here, could be a
|
After reading the discussion at #2369, this PR introduces a small addition to the docs which highlights how you can use server components within islands. This, coupled with the existing docs, should hopefully give people enough of an example to understand that islands provide the interactivity layer, and that server components within them can be hydrated and made interactive too. Closes #2369
Quoting @CAYdenberg in: #2363 (comment)
I also found this confusing at first. When should a file go under components/ versus islands/?
I had thought that islands were client-side and components were server-side, but that's not right. Instead, everything should be a component, except when it needs to be the root of a client-side hierarchy, and then it's an island. (Why? Because there are restrictions on what you can pass in to an island.)
In particular, the component page has some components tagged as islands that are really just components that can run on both client and the server. (A button could be an island, but why?)
The text was updated successfully, but these errors were encountered: