Pre DOM patch event listener #58596
Unanswered
darrelsilveira047
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hello, @inject IJSRuntime JSRuntime
@code {
protected override async Task OnInitializedAsync()
{
await JSRuntime.InvokeVoidAsync("initializeFunctionComponent");
}
public void Dispose()
{
JSRuntime.InvokeVoidAsync("disposeFunctionComponent");
}
} window.initializeFunctionComponent= (div_id) => {
// Initialize the component here
};
window.disposeFunctionComponent= (div_id) => {
// destroy the component here
}; Let me know. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Blazor Folks,
I’m using Blazor Server-Side Rendering (SSR) for my project without any interactivity modes, where the interactivity is handled exclusively via JavaScript. In my workflow, I have certain JS components (e.g., Tiny Slider) that need to be disposed of before Blazor applies any DOM updates (patches) to avoid conflicts.
Currently, I use a MutationObserver to detect DOM changes after they occur, but this approach is reactive and doesn’t prevent issues that occur during the DOM patching process itself.
Would it be possible to add an event listener or lifecycle hook that fires before Blazor begins DOM patching in SSR mode? This would allow developers to clean up or dispose of JavaScript components before DOM updates take place, similar to how an “unmount” or “pre-patch” hook works in other frameworks.
Thank you !
Beta Was this translation helpful? Give feedback.
All reactions