Blazor: Component re-renders even when onmousemove is null
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
Blazor components send a message to the server about mouse-move events even though the `@onmousemove` event callback has been set to null.
It would be useful if, when building the render tree, Blazor wouldn't include events that are null.
Take this example. Modify the SurveyPrompt in a default template.
```
...Omitted for brevity
@code {
..Omitted
private Action OnMouseMove { get; set; } = null;
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
System.Diagnostics.Debug.WriteLine("Rendered SurveyPrompt: " + (OnMouseMove == null));
}
}
```
Because OnMouseMove is null the component doesn't need to re-render every time the mouse moves over it.
This would be useful for components that implement events that the consumer can optionally set.
Contributor guide
Assessment
This issue has not been assessed yet.