Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #31429
Thanks @nitrospaz! 🚀 ... and sorry that you ran into trouble with the guidance.
Touch-ups
I made a few light touch-ups to where setting the namespace for components are called out. These didn't really need to be changed, but I made improvements that show an example of the
using
/@using
statement(s) with a placeholder ({APP NAMESPACE}
) and then an example of an actual statement withBlazorSample
as the app's namespace (e.g.,using BlazorSample.Components
).Bug 1 🪲
In order to use the shortened syntax for render modes, such as ...
@rendermode InteractiveServer
... the
_Imports.razor
file needs an additional@using
...@using static Microsoft.AspNetCore.Components.Web.RenderMode
Right at the time of release of the 8.0 framework, they tossed that
@using
statement into the_Imports.razor
file. I went around the repo updating examples to include the line; but unfortunately, I missed this article for that update 😢. Therefore, I'm adding that line now. I'm making a tracking note to confirm that there are no other spots around the repo that need the line.Bug 2 😈
This one is a little more painful to see, but I understand why it happened. It turns out ... AFAICT† ... that in order to embed an interactive Razor component into a page or view with the Component Tag Helper that the guidance is correct that
MapRazorComponents
is called withAddInteractiveServerRenderMode
chained on the call ...As you said in the issue, that section doesn't show or explain that the
App
component must be added to the app (and the namespace for it). The section that follows this section, the one that addresses routable components (i.e., not embedded into a page or view but actually routable by URL request) has theApp
component, but this section on embedding them doesn't. It only showsMapRazorComponents
with the rootApp
component specified.The interesting thing is that in order to embed components with the Component TH per this section, one doesn't really need a functional
App
component for that line AFAICT†. TheEmbeddedCounter
component works following the guidance in this section if theApp
component is just a no-op file ...Components/App.razor
:@* No-op App component *@
That brings me to the ...............
AFAICT† ... This didn't come up in conversations with the product unit (PU) when I was working on the coverage. We need to ask Mackinnon what he thinks about a no-op
App
component. If he thinks it's totally fine in this scenario, namely a RP/MVC app that will only embed non-routable interactive components into pages and views, then we can go ahead with these updates. He may have a known solution for this scenario that doesn't require a no-opApp
component. If he feels that we need to get more PU 👁️👁️👁️👁️ on this because the idea of a no-opApp
component seems strange or just flat-out wrong 🙈, then he'll ping some additional folks to look.The reason that this was missed is that the test app I was using here already had the
App
component present because I worked up the routable scenario first. Because it was already present, theMapRazorComponents
line didn't throw. I'm sorry now that I didn't work this section from a clean MVC app. At that time, I was 🏃 like crazy 😵 to get a massive amount of work done for release. Gremlins 😈 like this are virtually impossible to avoid working that fast.Because we're on a three-day weekend holiday, we probably won't get a response until next week. Stand-by .............
Internal previews