@using blazor_lifetime.Models @if (_isContentVisible) { @ChildContent } else { @if (LoadingContent != null) { @LoadingContent } } @code{ private bool _isContentVisible = false; [Parameter] public RenderFragment ChildContent { get; set; } [Parameter] public RenderFragment LoadingContent { get; set; } [Parameter] public IAsyncComponentBase Component { get; set; } protected override void OnInitialized() { if (Component == null) { throw new Exception(nameof(Component)); } Component.RenderChildContentAsync += OnRenderChildContentAsync; } protected async Task OnRenderChildContentAsync() { _isContentVisible = true; await InvokeAsync(StateHasChanged); } }