Skip to content

Commit 3034f2b

Browse files
committed
NotFound fragment cannot be conditionally added inside of Router and is not nullable. Use if-else instead.
1 parent a1e0e35 commit 3034f2b

File tree

1 file changed

+18
-9
lines changed
  • src/Components/test/testassets/Components.TestServer/RazorComponents

1 file changed

+18
-9
lines changed

src/Components/test/testassets/Components.TestServer/RazorComponents/App.razor

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,25 @@
4646
}
4747
else
4848
{
49-
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="new[] { typeof(TestContentPackage.NotFound.NotFoundPage).Assembly }" NotFoundPage="NotFoundPageType">
50-
<Found Context="routeData">
51-
<RouteView RouteData="@routeData" />
52-
<FocusOnNavigate RouteData="@routeData" Selector="[data-focus-on-navigate]" />
53-
</Found>
54-
@if (NotFoundPageType is null)
55-
{
49+
@if (NotFoundPageType is not null)
50+
{
51+
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="new[] { typeof(TestContentPackage.NotFound.NotFoundPage).Assembly }" NotFoundPage="NotFoundPageType">
52+
<Found Context="routeData">
53+
<RouteView RouteData="@routeData" />
54+
<FocusOnNavigate RouteData="@routeData" Selector="[data-focus-on-navigate]" />
55+
</Found>
56+
</Router>
57+
}
58+
else
59+
{
60+
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="new[] { typeof(TestContentPackage.NotFound.NotFoundPage).Assembly }">
61+
<Found Context="routeData">
62+
<RouteView RouteData="@routeData" />
63+
<FocusOnNavigate RouteData="@routeData" Selector="[data-focus-on-navigate]" />
64+
</Found>
5665
<NotFound><p id="not-found-fragment">There's nothing here</p></NotFound>
57-
}
58-
</Router>
66+
</Router>
67+
}
5968
}
6069
<script>
6170
// This script must come before blazor.web.js to test that

0 commit comments

Comments
 (0)