I'm trying to pass a List<string> from the child to the parent. I have a Action<List<string>> defined in the parent and I'm passing it as parameter to the child component. When an event happens within the child component, the expected result is that an updated List<string> is sent to the parent using the callback.
I'm getting compiler error Argument 2: cannot convert from 'method group' to 'EventCallback' in the parent component on <TagComponent UpDateNewTags="UpdateTags"></TagComponent>. If change the UpdateTags to UpdateTags() I get a different error. I also tried passing UpdateTags method as @(()=>UpdateTags) but that didn't work either. Now, I can go about putting the info that I want to pass to the parent in the session local storage and signal the parent to pick it up from there but that's admitting defeat.
How do I pass a List<string> from child to the parent on demand using event callback?
//Parent
<TagComponent UpDateNewTags="UpdateTags"></TagComponent>
// Parent function
public void UpdateTags (List<string> tags)
{
if (cpdto.NewTagTitles == null)
{
cpdto.NewTagTitles = new List<string>();
}
cpdto.NewTagTitles = tags;
}
//child component.
[Parameter]
public Action<List<string>> UpDateNewTags { get; set; }