Blazor Server-Side not re-rendering component after event is fired !
See original GitHub issueAs described in the title,i can’t see any re-rendering after ‘onclick’ is fired
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core ‘3 preview 7’
- Run this code
protected virtual void BuildCompnent(RenderTreeBuilder builder)
{
...
builder.AddContent(seq, _viewProperty.PropertyValue ?? "--SELECT--");
...
foreach (var item in SelectionDictionary)
{
builder.OpenElement(++seq, "a");
builder.AddAttribute(seq, "class", "font-weight-light btn-sm dropdown-item " + (item.Value == _viewProperty.PropertyValue ? "active" : ""));
builder.AddAttribute(seq, "onclick", () => ItemClicked?.Invoke(item.Key));
//builder.SetUpdatesAttributeName("onclick"); --> tried it but no help
builder.AddContent(seq, item.Value.ToString());
builder.CloseElement();
}
...
}
- The Action ‘ItemClicked’ is reached by the debugger , but component not showing “re-rendering” the selected item
Expected behavior
It should re-render the component by default when ‘onclick’ event is fired
Additional context
BTW this code was working like a charm in blazor 0.7 server-side but after updating to latest version…things got crackly
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Blazor component not refresh after event fired
The problem is, when I fire ItemSelected event, the class of the <tr> is not updated, however when I remove the line ItemSelected....
Read more >State Hasn't Changed? Why and when Blazor components ...
Here are the primary reasons your component will re-render: After an event occurs (when invoking an event handler in the same component); After ......
Read more >ASP.NET Core Blazor performance best practices
The event is dispatched to the component that rendered the event's handler. After executing the event handler, the component is rerendered. When ...
Read more >How to run code after Blazor component has rendered
This blog post will show you how to run code after your Blazor component has rendered, on every render or as needed. Sample...
Read more >Why is Blazor's rendering so inefficient?
The culprits were mainly over rendering too many things after events were fired (e.g re-rendering whole grid for unrelated field changes), as ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the linked blog post, it explains how you should handle this to avoid the
seq++
code.Thank you for contacting us. Due to no activity on this issue we’re closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn’t been addressed yet, please file a new issue.