Clarification on StateHasChanged
Behavior with Razor Syntax
#54771
Unanswered
Mike-E-angelo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was reading this documentation:
https://www.fluentui-blazor.net/Icon
In it, it provides the following Razor markup:
My understanding is that whenever
StateHasChanged
is called, any instructions within@()
get re-evaluated. If I understand correctly, each timeStateHasChanged
is called, it will result in another allocation to memory, ultimately adding to GC pressure for the process.Is my understanding correct? I have been wary of performing any activations in Razor markup due to this and would like to know if I am incorrect. Rather, I have been assigning allocations used in markup in the
OnInitialized
override where it seems this is called only once during the components lifetime (and therefore only one allocation).Thank you for any insight/clarification you can provide.
Beta Was this translation helpful? Give feedback.
All reactions