I have a razor page which depends on its parent's class and a second child which has its own class and receive data from its parent, my issue is on the second call to the api, the data is not being passed to the second child, the second child is not being render when its parent changes its data but it works on the first render and data is being passed.
Parent.razor
@inherits ParentBase;
<FirstChild/>
<SecondChild data="@data"/>
FirstChild.razor
@inherits ParentBase;
// call its parent method
<span @onclick='(() => callApi())'/>
ParentBase.cs
public class ParentBase : ComponentBase
{
public Data data { get; set; }
protected override async Task OnInitializedAsync()
{
data = await Services.GetData();
}
// call from a child
public void callApi
{
data = await Services.GetData();
}
}
SecondChild.razor
<Table data="@data"/>
SecondChildBase.cs
public class SecondChildBase : ComponentBase
{
[Parameter]
public Data data { get; set; }
protected override void OnParametersSet()
{
// this is not getting called
StateHasChanged();
Console.WriteLine(data);
}
}