Why and when Blazor components re-render
published on 2023/04/17
Sooner or later, as you build out your Blazor UI, you’re going to hit a situation where your component isn’t re-rendering when you expect it to.
The result? You’re stuck staring at “stale” data, scratching your head as to why the value hasn’t updated.
Sometimes a quick call to StateHasChanged is all you need to get back up and running but what’s really going on behind the scenes?
Blazor components (technically called Razor Components… naming is hard) typically inherit from a class called ComponentBase.
ComponentBase has some default behaviour baked in to determine when your component will be re-rendered.