Skip to content

Instantly share code, notes, and snippets.

View chrissainty's full-sized avatar
🔥

Chris Sainty chrissainty

🔥
View GitHub Profile
@SQL-MisterMagoo
SQL-MisterMagoo / App.razor
Created December 29, 2019 00:33
Sample code to handle deep links to anchors in Blazor components
@* Code below handles deep links to anchors through the entire application *@
@inject NavigationManager NavMan
@inject IJSRuntime JS
@code
{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && NavMan.Uri.Contains('#'))
{
@SteveSandersonMS
SteveSandersonMS / sequence-number.md
Last active November 28, 2023 20:28
Why sequence numbers should relate to code line numbers, not execution order

Why sequence numbers should relate to code line numbers, not execution order

Or in other words, why you should hard-code sequence numbers, and not generate them programmatically.

Unlike .jsx files, .razor/.cshtml files are always compiled. This is potentially a great advantage for .razor, because we can use the compile step to inject information that makes things better or faster at runtime.

A key example of this are sequence numbers. These indicate to the runtime which outputs came from which distinct and ordered lines of code. The runtime uses this information to generate efficient tree diffs in linear time, which is far faster than is normally possible for a general tree diff algorithm.

Example