I've tried different ways to prevent this from happening.
After changing to render-mode="Server" I was able to prevent rendering twice on the first load.
But now when I refresh the page it still doubles the amount of elements.
Here is what I've got
<div id="component-wrapper" class="row">
@if (Items != null)
{
@foreach (var item in Items )
{
<ItemComponent Item="@item" />
}
}
</div>
@code {
[Inject]
private IItemService ItemService { get; set; }
List<ItemViewModel> Items { get; set; }
protected override async Task OnInitializedAsync()
{
Items = await ItemService.GetItemsAsync();
base.OnInitialized();
}
}
I've read over the Stateful reconnection after prerendering section and it doesn't seem to work for me.
For me it was that this script was duplicated on _Hosts.cshtml
<script src="_framework/blazor.server.js"></script>
After deleting one of them problem was solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With