create component using RenderTreeBuilder

This commit is contained in:
sbwalker
2024-02-09 15:46:44 -05:00
parent ea75ddfa85
commit df4d4d36bc
2 changed files with 12 additions and 7 deletions

View File

@ -14,7 +14,7 @@
{
<ModuleMessage Message="@_messageContent" Type="@_messageType" />
}
<DynamicComponent Type="@ModuleType" Parameters="@ModuleParameters"></DynamicComponent>
@DynamicComponent
@if (_progressIndicator)
{
<div class="app-progress-indicator"></div>
@ -37,7 +37,7 @@ else
@code {
private Type ModuleType { get; set; }
private IDictionary<string, object> ModuleParameters { get; set; }
RenderFragment DynamicComponent { get; set; }
private string _messageContent;
private MessageType _messageType;
@ -77,7 +77,12 @@ else
ComponentSiteState.RemoteIPAddress = SiteState.RemoteIPAddress;
ComponentSiteState.IsPrerendering = SiteState.IsPrerendering;
ModuleParameters = new Dictionary<string, object> { { "RenderModeBoundary", this } };
DynamicComponent = builder =>
{
builder.OpenComponent(0, ModuleType);
builder.AddAttribute(1, "RenderModeBoundary", this);
builder.CloseComponent();
};
}
else
{