Rerendering of component with multiple classes
- Dominant language
- C#
- Stars
- 193
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
Let's say we have a component called <`MasterComponent>`. This component has style definitions within declared using ``.
When the component has a single css class defined in it, the component's OnAfterRender method is called twice, which is standard. Also the `` component's OnAfterRender is called twice. This is fine.
When you have 2 css classes, each class gets rendered 3 times and `` OnAfterRender method is called 3 times aswell.
When you have 20 css classes, each class gets rendered 21 times (for a total of 420 renders) and the ``'s OnAfterRender is called 21 times too.
When I create a `` with 20 css classes and I render it 10 times in `` and I also render `` 10 times, I get 46200 calls to OnAfterRender on `` components. That's a lot. This problem could get really bad in larger applications where you can get to millions pretty easily.
I think this is a big contributor to the performance problems in v3 mentioned here https://github.com/chanan/BlazorStyled/issues/104
To be completely honest, I have no idea why it happens. Maybe you'll understand it better.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the described render-count scenarios for MasterComponent, ChildComponent, and Styled, then compare the results with the performance concerns in issue #104. Done means the number of OnAfterRender calls no longer grows with each CSS class and nested render, with the observed counts documented or covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, css
- Domain
- frontend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100