Parent component:
@page "/parent-component<ChildComponent @bind-Name="@name" /><h1>@name</h1>@code { private string name = "Hugo";}Child component:
<button @onclick="UpdateName">Update</button>@code { [Parameter] public string Name { get; set; } [Parameter] public EventCallback<string> NameChanged { get; set; } private async Task UpdateName() { Name = $"Hi {Name}"; await NameChanged.InvokeAsync(Name); }}When going to the url /parent-component, the H1 says Hugo. And when I click on the button, the text updates to "Hi Hugo" - just as expected.
However, is it possible to remove the button, and have the child do it logic, in this case just to add "Hi", when the component is rendered?
I have tried using OnInitializedAsync, and OnParametersSetAsync but that don't update the value on the parent component.