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.

OnAfterRender being called after every scrolling via javascript

See original GitHub issue

I am initiating a scroll to a specific element from OnAfterRender override. I am scrolling in multiple steps to animate the scroll but I am noticing that after each step of scrolling is complete, OnAfterRender is getting called. Is this expected?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nvmkpkcommented, Mar 29, 2020

What event are you talking about? I did not register for any event. I am just invoking element.scrollTo from OnAfterRender override of my component via JS interop. And OnAfterRender is getting called after that scrolling is complete. I don’t think blazor is re-rendering. I will see if I can provide a simple project to reproduce the issue.

0reactions
nvmkpkcommented, Sep 25, 2020

That is an ugly work around. I hoped for a solution like adding @on{EVENT}:disableRerender="true" to prevent re-render.

I think I will go the route of a custom base class implementing IComponent and IHandleEvent interface to permanently disable the call to StateHasChanged on handling any events. (along with other related interfaces).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor OnAfterRenderAsync Javascript
So I've been playing around with Blazor WebAssembly and I can't figure out how to solve this problem. Basically, I have a NavMenu.razor...
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.
Read more >
onAfterRender not called after grid scrolling - ZK Forum
One solution seems to be calling grid.renderAll() [2], for example in doAfterCompose. That way the wireEvents finds all the rows. Is there any...
Read more >
Call JavaScript functions from .NET methods in ASP. ...
This article explains how to invoke JavaScript (JS) functions from .NET. For information on how to call .NET methods from JS, see Call...
Read more >
What are the application lifecycle methods in Blazor?
OnAfterRenderAsync (bool firstRender). This is the asynchronous method which is executed when the rendering of all the references to the component are ...
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 Reddit Thread

No results found

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