Xiphe / remix-island

utils to render remix into a dom-node instead of the whole document
MIT License
131 stars 7 forks source link

Add support for Layout export #16

Closed silvenon closed 1 month ago

silvenon commented 1 month ago

This lets people use Remix's Layout export without it affecting the Head export. Because the hack includes changing the Head export to default, Layout gets applied to Head, which results in wrapping Layout around the Head during SSR 😬 (renderHeadToString)

This fix excludes the Layout export from root route module exports in remixContext during SSR.

I'm aware that there might not be much interest in maintaining this library anymore for various reasons, one being that React v19 feels right around the corner. But until then it isn't here yet 😄

If someone stumbles upon this unmerged, you can easily modify the remixContext that you're passing to renderHeadToString in entry.server.ts to omit Layout just like in this diff.

I bumped development dependencies because this library has been built for Remix v1, and Layout export has been released in v2. Let me need if I need to walk any updates back.

Fixes #15

jgentes commented 1 month ago

That's for doing this work, I haven't migrated to the new Layout yet but I plan to.

Xiphe commented 1 month ago

Thanks for bringing this in!

silvenon commented 1 month ago

My pleasure! 🚀 I'm glad that the fix was so simple.