Skip to content

Commit 9e86652

Browse files
committed
Prevent boxing allocation for Inertia.Html
1 parent 6c21508 commit 9e86652

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

InertiaNetCore/Inertia.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public static class Inertia
1919

2020
public static Response Render(string component, Dictionary<string, object?>? props) => _factory.Render(component, InertiaProps.Create(props));
2121

22-
public static Task<IHtmlContent> Head(dynamic model) => _factory.Head(model);
22+
public static Task<IHtmlContent> Head(InertiaPage model) => _factory.Head(model);
2323

24-
public static Task<IHtmlContent> Html(dynamic model) => _factory.Html(model);
24+
public static Task<IHtmlContent> Html(InertiaPage model) => _factory.Html(model);
2525

2626
public static void SetVersion(object? version) => _factory.SetVersion(version);
2727

InertiaNetCore/ResponseFactory.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task<IHtmlContent> Head(dynamic model)
4040
return response.Value.GetHead();
4141
}
4242

43-
public async Task<IHtmlContent> Html(dynamic model)
43+
public async Task<IHtmlContent> Html(InertiaPage model)
4444
{
4545
if (options.Value.SsrEnabled)
4646
{
@@ -49,7 +49,7 @@ public async Task<IHtmlContent> Html(dynamic model)
4949
var response = context.Features.Get<SsrResponse?>();
5050
response ??= await ssrGateway.Dispatch(model, options.Value.SsrUrl);
5151

52-
if (response.Value != default)
52+
if (response != null && response.Value != default)
5353
{
5454
context.Features.Set(response);
5555
return response.Value.GetBody();

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ If you want to enable SSR in your Inertia app, remember to add `Inertia.Head()`
287287

288288
```diff
289289
@using InertiaNetCore
290+
@model InertiaNetCore.InertiaPage
290291

291292
<!DOCTYPE html>
292293
<html lang="en">

0 commit comments

Comments
 (0)