EventCallback<T> Error cannot convert from 'method group' to 'EventCallback'
See original GitHub issueDescribe the bug
Using the following two components, the compiler emits an error in the Parent component in the OnSelect event parameter.
Error cannot convert from ‘method group’ to ‘EventCallback’
<Child Data="@Data" OnSelect="@OnSelect">
</Child>
Is this an issue or I am doing this wrong ?
To Reproduce
@*Parent.razor*@
@page "/Parent"
<div>
<Child Data="@Data" OnSelect="@OnSelect">
</Child>
</div>
@functions {
List<Item> Data = new List<Item>();
private void OnSelect(Item item)
{
}
}
@*Child.razor*@
@typeparam TData
<div>
@foreach (var item in Data)
{
<button onclick="@(() => OnSelect.InvokeAsync(item))"></button>
}
</div>
@functions {
[Parameter]
public IEnumerable<TData> Data { get; set; }
[Parameter]
private EventCallback<TData> OnSelect { get; set; }
}
// Item.cs
public class Item
{
public Item()
{
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
cannot convert from 'method group' to 'EventCallback' - ...
I have a parent component and a child component with an event callback where I want it to pass back a type of...
Read more >Cannot convert from method group to EventCallBack?
The code works fine when it the method is in the same file, but when I place it on another file it gives...
Read more >cannot convert from 'method group' to 'EventCallback'
Hello, Can't understand what I'm doing wrong? Argument 2: cannot convert from 'method group' to 'EventCallback': Demo works.
Read more >cannot convert from 'method group' to 'EventCallback'-blazor
The event handler expects a delegate EventCallback that can accept up to 1 parameter of type InputFileChangeEventArgs . Think of a delegate as...
Read more >Cannot convert void to EventCallback in Blazor
I had created a simple method in a Razor page in my Blazor app ... me the error “Argument 2: cannot convert from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Using async and Task does not change anything - the error remains.
The only way I am able to make it work is by doing the following in the Parent component event handler :
instead of :
Seems kind of strange to me that it would need to be done that way though.
Hey I have Installed Preview 7 but I still get this error, shouldn’t this be fixed?