Skip to content

Commit 90f6f0f

Browse files
committed
Feedback: use RouteView.
1 parent 8d96617 commit 90f6f0f

File tree

1 file changed

+5
-14
lines changed
  • src/Components/Components/src/Routing

1 file changed

+5
-14
lines changed

src/Components/Components/src/Routing/Router.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,14 @@ private void RenderNotFound()
398398
{
399399
if (NotFoundPage != null)
400400
{
401+
builder.OpenComponent<RouteView>(0);
402+
builder.AddAttribute(1, nameof(RouteView.RouteData),
403+
new RouteData(NotFoundPage, _emptyParametersDictionary));
401404
if (_notFoundLayoutType is Type layoutType)
402405
{
403-
// Directly instantiate the layout type, supplying the NotFoundPage as the Body
404-
builder.OpenComponent(0, layoutType);
405-
builder.AddAttribute(1, LayoutComponentBase.BodyPropertyName,
406-
(RenderFragment)(childBuilder =>
407-
{
408-
childBuilder.OpenComponent(2, NotFoundPage);
409-
childBuilder.CloseComponent();
410-
}));
411-
builder.CloseComponent();
412-
}
413-
else
414-
{
415-
builder.OpenComponent(0, NotFoundPage);
416-
builder.CloseComponent();
406+
builder.AddAttribute(2, nameof(RouteView.DefaultLayout), layoutType);
417407
}
408+
builder.CloseComponent();
418409
}
419410
else if (NotFound != null)
420411
{

0 commit comments

Comments
 (0)