I have a simple child Blazor component (MyModal) like so:
<div class="modal">
<h3>@Title</h3>
@BodyTemplate
</div>
@code
{
[Parameter] string Title { get; set; }
[Parameter] RenderFragment BodyTemplate { get; set; }
}
In my Parent component I'm calling it like so:
<MyModal Title="Super Cool Modal">
<BodyTemplate>
@MyObject.Name
</BodyTemplate>
</MyModal>
public MyObject MyObject { get; set; } = new MyObject();
Later on after the page has initially rendered I update MyObject
but the Child component itself referencing @MyObject.Name
never updates.
Seems I have to force refresh on the child object after I've updated the Object (StateHasChanged
) but not sure how to do this with this example.