fresh
fresh copied to clipboard
feat: support nested islands (alternative)
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 https://github.com/denoland/fresh/issues/168 and https://github.com/denoland/fresh/issues/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.
@lucacasonato I noticed the roadmap mentioned supporting
anywhere in the tree.I feel like the context approach (from this PR) to track island during render could still help to accomplish that goal, especially as a way to support indifferent usage of head between server side and client side.
However, in light of the roadmap goals, I was wondering if this PR needs any changes?
Thanks for the PR! Apologies that we couldn't get it over the finish line. In the end we went with the approach in #1285 to support nested islands.