Skip to content

Instantly share code, notes, and snippets.

@simonziegler
Last active June 18, 2021 06:27
Show Gist options
  • Save simonziegler/5c54c1a904ef7706ba2a45653753f894 to your computer and use it in GitHub Desktop.
Save simonziegler/5c54c1a904ef7706ba2a45653753f894 to your computer and use it in GitHub Desktop.
CascadingValue is hopefully not null
@if (stuff)
{
<div>Stuff</div>
}
else
{
<div>More Stuff</div>
}
@code
{
[CascadingParameter]
private WrapperComponent TheWrapper { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
// `TheWrapper` should not be null here
}
}
@page "/mypage"
<WrapperComponent>
<ChildComponent />
</WrapperComponent>
@using Recyclarr.Radarr
<CascadingValue Value="this" IsFixed="true">
<div>
@if (some_error_occurred)
{
<div>Show an error</div>
}
else
{
@ChildContent
}
</div>
</CascadingValue>
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment