fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Feature: Client only lazy loaded island components

Open vorcigernix opened this issue 2 years ago • 2 comments

For some of the components it does not really make sense to render them on the server (eg they require window object). A similar functionality could be achieved by adding

  if (!IS_BROWSER) {
    return <div>Loading...</div>;
}

but in the situation I described it would be better if the framework knows that this component is not going to work on the server and avoid the server part completely. Similar to https://nextjs.org/docs/advanced-features/dynamic-import

vorcigernix avatar Jul 04 '22 11:07 vorcigernix

Every component on the islands will be hydrated on the client (if js is enabled). Wouldn't be easier to in that component, that has a state, to get the condition?

if (!data) return <div>Loading…</div>

imaginamundo avatar Jul 06 '22 00:07 imaginamundo

Mh, how would this work? What would be rendered in place of the component on the server? I think your IS_BROWSER example is exactly how I envision that this should work.

lucacasonato avatar Aug 09 '22 20:08 lucacasonato

Yes, it is not super important and it is solvable. My thinking was that sometimes you don't need the server render part at all so it could be "cheaper on the server" to just skip it.

vorcigernix avatar Sep 23 '22 07:09 vorcigernix