dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.27k stars 9.96k forks source link

Static Pages should support Interactive components fully #57709

Closed garrettlondon1 closed 3 weeks ago

garrettlondon1 commented 3 weeks ago

Summary

Currently, there is a very ugly workaround if you want to support interactive components on static pages, where you have to wrap the interactive components in a parent component if you need to pass in non-serializable child content

Motivation and goals

Make it easier to consume interactive components from static pages

image

Documentation explains the serializable parameters, but why is this the case? Blazor should know that a component is InteractiveServer, and it should support sending child content to interactive server components on static pages

Examples

Cannot pass the parameter 'ChildContent' to component - main error received

image

Detailed design

Static pages should be able to support interactive components, even if you nest them with non-serializable content

javiercn commented 3 weeks ago

@garrettlondon1 thanks for contacting us.

I'm going to mark this as a dupe of https://github.com/dotnet/aspnetcore/issues/52768, which is the best we could do.

That said, this proposal is simply not feasible. If the parameters are not serializable, they can't run on Web assembly, which is a completely separate host. It could potentially work on server, but that wouldn't be a trade-off we would make. Wrapping inside an additional component it's an acceptable enough alternative for this situation when you need to cross process boundaries.

garrettlondon1 commented 3 weeks ago

@javiercn , yeah I am exclusively thinking about server. It's not productive for InteractiveServer BWA developers to wrap every single interactive component inside of another.

Couple this with #56413 and now you are creating so many extra components just to use Error Boundaries and static pages.

You need a static page, a wrapping component, and to ensure that you wrap every single html onclick handler in another component.

It's super unproductive