-
Notifications
You must be signed in to change notification settings - Fork 10.7k
[Blazor] Support serializing render fragments from SSR #52768
Copy link
Copy link
Labels
Pillar: Complete Blazor WebPriority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsfeature-blazor-ssron-roadmapListed on the current release roadmapListed on the current release roadmaptriaged
Milestone
Metadata
Metadata
Assignees
Labels
Pillar: Complete Blazor WebPriority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsfeature-blazor-ssron-roadmapListed on the current release roadmapListed on the current release roadmaptriaged
Type
Fields
Give feedbackNo fields configured for Feature.
Currently we don't support serializing RenderFragments as root component parameters.
This has obvious drawbacks like our inability to render components with a body as a root component (That's why we need to have extra components like Routes.razor) on the template or why we can't have @RenderMode applied to things like Layout components.
To support these types of scenarios, we can support serializing the contents of the render fragment statically and re-applying those contents on the interactive side.
The way it will work is as follows:
For the most part, this will work for static content and will also work for even components, provided that the parameters in the components are serializable.
This will mean that we can for example, apply
@rendermodeto things likeCascadingValueprovided that theTused is serializable, and the components inside the body are serializable too.To avoid situations where we close over server state, we can require the compiler to make the function a static local function when it is passed to a component with a rendermode or
@rendermodeis used as an attribute. You could still get into weird situations if you try to access static variables, but I think that's acceptable.