Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (29 sloc) 794 Bytes
@inject Blazored.LocalStorage.ILocalStorageService localStorage
@if (_visible)
{
<div class="col-md-12 banner">
<button @onclick="@Dismiss" class="float-right btn">x</button>
A very important message
</div>
}
@code {
private bool _visible = false;
private async Task Dismiss()
{
_visible = false;
await localStorage.SetItemAsync("bannerDismissed", true);
}
protected override bool ShouldRender()
{
var shouldRender = base.ShouldRender();
return shouldRender;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
_visible = !await localStorage.GetItemAsync<bool>("bannerDismissed");
StateHasChanged();
}
}
}
You can’t perform that action at this time.