Closed moonlitknight closed 3 days ago
By default, Astro uses the name of the componet to resolve it when rendering the island, but since you change the component to ComponentToRender
, it's not able to find Card.astro
anymore.
This is required by the Astro rendering engine.
Check the proposal for the internal requirements https://github.com/withastro/roadmap/blob/main/proposals/0050-server-islands.md#island-rendering
That's fine. It might be worth including in the server islands documentation as it's reasonable for developers to expect that adding "server:defer" to a working component should not break it.
On Mon, 18 Nov 2024 at 14:56, Emanuele Stoppa @.***> wrote:
Closed #12458 https://github.com/withastro/astro/issues/12458 as not planned.
— Reply to this email directly, view it on GitHub https://github.com/withastro/astro/issues/12458#event-15334830322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4M266XZIMEG2PYAN3SZK32BHWYDAVCNFSM6AAAAABR567ZD2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJVGMZTIOBTGAZTEMQ . You are receiving this because you authored the thread.Message ID: @.***>
Thank you. I will bring this up with the team and see what's the best course of action
What you might want to do is the following:
{
ComponentToRender === 'Card' ? (
<Card server:defer />
) : ComponentToRender === 'Other' ? (
<Other server:defer />
) : ...
}
Astro relies on static analysis at the compiler level to determine the component to render. This is true for client directives too.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
tl;dr adding "server:defer" to my component causes error
My code is unusual insofar as, I do not render the component by name, but rather I instantiate an object that contains the component object and render that. This works fine without server islands, but fails if I add "server:defer".
See the
index.astro
file in the attached Stackblitz to see the minimal code and some additional notes on why I am doing this.What's the expected result?
I expect my component to render.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-u2cja6?file=src%2Fpages%2Findex.astro&title=Astro%20Starter%20Kit:%20Basics
Participation