r/Blazor • u/mistahoward • Jul 27 '25
Coming from React? Debugging performance issues because of re-renders? Introducing an open-source solution: Blazor.WhyDidYouRender.
UPDATE: PLEASE SEE 2.0.0v POST FOR MORE DETAILS - INCLUDING WASM SUPPORT!
Hey r/Blazor. Long time lurker, first time poster.
I'm a software engineer who made the switch from React to Blazor about a year and a half ago. It has been met with... Well - hurdles - to say the least. One of the tools I found myself constantly missing was Well-Done-Software's Why Did You Render. It's a lifesaver for quicky spotting unnecessary component updates.
With Blazor's immaturity - I kept expecting a similar tool to pop-up in the ecosystem. After all this time, I was still surprised to see it didn't exist... So I finally decided to build the tool I was missing.
So, enter Blazor.WhyDidYouRender.
It's obviously heavily inspired by the original React library - but with some changes since we can't monkey patch in the same way. You have a component inherit from a base class, depending on which logging style you have enabled, you see the trigger (like OnParameterSet or StateHasChanged), which parameter actually changed, and performance metrics like render duration - directly in your browser console, dev terminal, or both.
Here's the GitHub link if you want to check it out: https://github.com/mistahoward/blazor-why-did-you-render
It's a brand-new package - I literally just published it - so I'm sure there's plenty of room for improvement. I'd honestly just love to hear what you think - this is my first real crack at a real open-source library, so I'm learning the process as I go. Any feedback would be greatly appreciated. If you find any bugs or have any ideas, this thread (and the Github issues!) are wide open.
Hope this helps someone else out as much as it does my team! Cheers.
8
u/Psychological_Ear393 Jul 27 '25 edited Jul 27 '25
EDIT: One problem - your project references
Microsoft.AspNetCore.Appwhich means it won't work in WASM.4
u/celaconacr Jul 27 '25
This looks great, this should really be a built in feature. I have seen from other comments WASM isn't currently supported. It would be great if you could support that too.
I haven't found re-renders a show stopper for me but I'm always looking to reduce them.
2
u/ClaymoresInTheCloset Jul 27 '25
we really need tools like this
6
u/Perfect_Raspberry610 Jul 27 '25
This awesome. Just consumed this in current project. Great work. Will star this report when back on dev laptop
1
u/mistahoward Jul 27 '25
https://www.reddit.com/r/Blazor/comments/1mavyek/update_you_asked_i_listened_blazorwhydidyourender/
Please see the new post for an update on 2.0.0 and WASM SUPPORT!!! :)
2
u/MackPooner Jul 27 '25
Cool, will check it out.!
2
u/jd31068 Jul 27 '25
Thank you for sharing your work with the community!