feat: support nested islands (alternative) #517
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch is an alternate to #459 that adds support for nested islands. As discussed, the way this change handles nested islands is to use an island context to track whether the component is within an island or not. This should address the problems mentioned in #168 and #178.
Additionally, this change has a second commit exposing a
useWithinIsland
component which would let components detect whether they are being loaded within an island. I'm not sure if the addition of this is a good fit for the framework long term. I could see it being used in cases where a component library (one specifically designed for fresh) would need to do different things on render e.g. modifications to<head>
. Since there are likely pros and cons to this, I'm happy to split it into another PR so it can be discussed separately.Future idea 💡 – I could also see a way that the island context could open a path to get the
<Head>
component working in the browser.