Skip to content

[Blazor] Add a way to indicate event handler should not call StateHasChanged #22236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrpmorris opened this issue May 26, 2020 · 1 comment
Closed
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@mrpmorris
Copy link

mrpmorris commented May 26, 2020

When adding @onmousemove=MouseHasMoved to an element Blazor will re-render the component every time the MouseHasMoved method finishes executing.

Preventing this using ShouldRender is tricky, because the component might need to render for other reasons, and having to set some state for every scenario that causes a re-render is labourious.

Could we have a way of telling Blazor not to add a call to StateHasChanged. Perhaps something like this

@onmousemove:preventStateHasChanged
@onmousemove:preventStateHasChanged=true
@onmousemove:preventStateHasChanged=LeftMouseButtonIsHeldDown

@Pilchie Pilchie added the area-blazor Includes: Blazor, Razor Components label May 26, 2020
@mrpmorris mrpmorris changed the title [Blazor] Add a way to prevent render from a method or event [Blazor] Add a way to indicate event handler should not call StateHasChanged May 27, 2020
@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
This is a dupe of #18919

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label May 27, 2020
@ghost ghost added the Status: Resolved label May 27, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants