question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blazor server renders twice resulting in static HTML animation showing twice

See original GitHub issue

All over the web there have been discussions about how Blazor server hits the OnInitialized method twice, once in prerendering and again after the connection has been established in the browser. All the above address data and how to preserve the state after prerendering.

I am using .Net 6 and have a pure static HTML razor component that has an animation done in CSS. The animation occurs twice. In development this occurs so fast that it is almost not conceivable to the user. The same when live but using a strong internet connection. When accessing it via a slow internet connection the animation occurs twice.

I have created a reproducible solution which shows the effect https://github.com/aryehsilver/BlazorDoubleRenderTest.

I also have published live where you can see it in action (using a slow connection) https://projects.aryehsilver.co.uk/double-render.

Here is a clip of the animation in action.

https://user-images.githubusercontent.com/55258552/153734618-23707cb4-3340-4c4b-8cf3-efa249af0b0e.mp4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Freshmintyycommented, Jul 23, 2022

I’m also experiencing the same problem with the entrance animations for html elements. How can we provide make this better for our users? We only want the animation to play once rather than playing once then half way through resetting and playing again

0reactions
danroth27commented, Nov 21, 2022

We are tracking addressing this issue as part of https://github.com/dotnet/aspnetcore/issues/42561

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor Server: OnInitialized Method Triggered Twice ...
This is causing a static HTML razor component that has an animation done in CSS to animate twice.
Read more >
Exclude part of Html from rerendering : r/Blazor
I'm using Blazor Server hosting model and set render-mode to ServerPrerendered therefore page will be rendered twice (once as a static page ...
Read more >
Page animations are shown twice with Blazor - Aryeh Silver
When showing a pure static HTML razor component that has an animation done in CSS, the animation occurs twice. In development this occurs...
Read more >
Why are Blazor lifecycle methods getting executed twice?
When the component is rendering with the ServerPrerendered render mode, the component is initially rendering statically as part of the page. On executing...
Read more >
[Solved]-how to stop rendering twice (for non-data retrieving ...
In a Blazor Server app when RenderMode is ServerPrerendered, the component is initially rendered statically as part of the page. Once the browser...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found