I'm not clear on how to get a Blazor (Server) component to react to a change to one of it's parameters.
So, this is a cut-down version of my Component
@foreach (var msg in this.Data)
{
<div class="bg-danger text-white">
<div>@msg</div>
</div>
}
@code
{
[Parameter]
public IList<Something> Data{ get; set; } = null!;
}
Then in my Page I have
<mycomponent Data="@StuffForComponent"><mycomponent>
@code
{
private List<Something> StuffForComponent {get;} = new List<Something>();
private async Task HandleSomeEvent()
{
var r = await this.Service.GetSomething().ConfigureAwait(false);
this StuffForComponent.AddRange(r.Stuff);
}
}
So the idea is that the Component gets created when the page loads, and the empty list gets passed to its input parameter.
Sometime later, we handle a user-event and this adds data to that list. However, the Component doesn't react to the changed list.
What do I need to do to make the component react to new entries being added, or deleted, from this list?
StateHasChanged()after `AddRange? - dani herrera