How to Fix the Issue with Blazor Prerendering - OnInitialized Gets Called Twice - Abhay Prince

  Рет қаралды 4,645

Abhay Prince

Abhay Prince

Күн бұрын

Пікірлер: 30
@srinivasanhariharan6489
@srinivasanhariharan6489 20 күн бұрын
Super explanation and it worked nice
@GodwinMathias
@GodwinMathias 11 ай бұрын
Wow!!! am eternally grateful for this. it just help me solved my biggest problem with the prerendering and the oninitialized method. Kudos
@jsiahaan
@jsiahaan Жыл бұрын
Thank you very much. Very useful video
@MoogieWarren
@MoogieWarren 4 ай бұрын
Great video Abhay! One question: I don't believe we still need the subscription and the dispose method on the Weather.razsor file. Do you agree?
@MoogieWarren
@MoogieWarren 4 ай бұрын
And another question.... I am observing no flicker/"loading..." between the prerender and the WASM data retrieval when I hit the page the first time (context: this is a file in the *.client project) (which is awesome, you are the man). However, I do see flicker/"loading..." when I move from the page in question and go to another, then go back to the original (the one implementing BasePage, not all pages are implementing BasePage). Do you know why this is and what can be done to avoid it? P.S. I pulled down this example project, and it demonstrates the same behavior. Much Thanks!
@QVictahQ
@QVictahQ 5 ай бұрын
Thank you! Is this applicable to Blazor server app?
@abhayprince
@abhayprince 5 ай бұрын
Yes
@gabrielhvd
@gabrielhvd 5 ай бұрын
Could this apply for WebAssembly model? I'm facing a issue where my WebAssembly Blazor App is calling the OnInitizalizeAsync mehotd several times and I don't know why. Thanks for the video!
@abhayprince
@abhayprince 5 ай бұрын
Yes, only if Pre-rendering is enabled
@hashimal-mansouri9163
@hashimal-mansouri9163 Жыл бұрын
THX
@Buckanian
@Buckanian 10 ай бұрын
is this applicable to the blazor SSR template
@abhayprince
@abhayprince 10 ай бұрын
SSR is statically server side rendered, so this problem does not exists there. This video is about Interactive Modes which first prerenders the content on server and then renders again on client
@manojnaik5643
@manojnaik5643 8 ай бұрын
Nice Explanation, can you please guide how to apply this logic to call basepage class in webassembly client pages, I am new in blazor. getting error "The registered callback b__0 must be associated with a component or define an explicit render mode type during registration." I am using client and server webapp interactive mode.
@wherryd
@wherryd 6 ай бұрын
To solve this, you just need to explicitly set the render mode for your RegisterOnPersisting method: _subscriptions.Add(ApplicationState.RegisterOnPersisting(() => { ApplicationState.PersistAsJson(key, data); return Task.CompletedTask; }, RenderMode.InteractiveAuto));
@eduardogoncalvesdossantos4323
@eduardogoncalvesdossantos4323 5 ай бұрын
@@wherryd , PROBLEM SOLVED!!!! THANKS!!!!
@andymesta4913
@andymesta4913 2 ай бұрын
When you change the page and come back it no longer works
@anushakondra7778
@anushakondra7778 Жыл бұрын
how to solve this issue(onintialised method calling twice) in .net 7. Rendermode is available only for .Net 8 version as in your case.
@abhayprince
@abhayprince Жыл бұрын
You can use the second approach I showed. using PersistComponentState
@anushakondra7778
@anushakondra7778 Жыл бұрын
does persistComponentState work without injecting rendermode[InteractiveServer] ?? i have tried second method, but the api call was made twice.
@MiguelÁngelCardonaVillagomez
@MiguelÁngelCardonaVillagomez Ай бұрын
This is NOT working, when navigating to another Page and going back to Weather, the OnInitializedAsync() executes 3 times! First 2 it goes through the await Task.Delay(500); and third time it actually skips it. Can you please explain? I downloaded your code sample. If you delay to 5000 this will be more notorious.
@abhayprince
@abhayprince Ай бұрын
@@MiguelÁngelCardonaVillagomez Interesting. I will check and update here
@goditto5694
@goditto5694 8 ай бұрын
Thank you fo rthis video. But Aren't the descriptions mutually contradictory? Of course, I understand that the Interactive mode of a WebApp obviously renders twice, once on the server side and once on the client side, From the way you describe it, When the server finishes rendering, the client get fetches the all that data from the server. In your example, the rendered data didn't actually exist on the client's source with InteractiveServerMode. So how is it possible to explain that the client renders the same OnInitializedAsync() logic again? They seem to contradict each other.
@krugovi
@krugovi 10 ай бұрын
Hi. Great video, but I have one problem. The first time everything works ok, but after changing the page, and returning back, the delegate method that was sent to "GetOrAddState" is executed, but the screen is not updated, and it keeps saying "Loading..."
@abhayprince
@abhayprince 10 ай бұрын
Strange. I need to check it. For now you can try calling StateHasChanged() method
@krugovi
@krugovi 10 ай бұрын
in debug mode, error : "System.InvalidOperationException: The registered callback b__0 must be associated with a component or define an explicit render mode type during registration." (VS : 17.8.5, last update : 19.01.2024.)
@sebastianolaf
@sebastianolaf 9 ай бұрын
Hi I try to implement this and got this error below, need your help InvalidOperationException: The registered callback b__0 must be associated with a component or define an explicit render mode type during registration.
@abhayprince
@abhayprince 9 ай бұрын
Are you using it with SSR?
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 55 МЛН
The Biggest ISSUE With Blazor (and how to fix it)
6:57
Codewrinkles
Рет қаралды 10 М.
South Korean National Assembly rejects President’s martial law declaration
18:53
Ollama on Kubernetes: ChatGPT for free!
18:29
Mathis Van Eetvelde
Рет қаралды 10 М.
Beautiful Sortable Drag & Drop Lists for your Blazor Apps
32:11
Blazor Basics: Cascading Parameters
29:15
Just Blazor Programming
Рет қаралды 3,4 М.
.NET 8 Blazor New Forms Functionality Explained
22:50
Coding with Tom
Рет қаралды 10 М.
B2C is dead - long live Entra External ID!
40:46
Alexander Schmidt (codingfreaks)
Рет қаралды 5 М.
Doing More with SSR Blazor in .NET 8
17:03
Isaac Levin
Рет қаралды 2,6 М.
Players push long pins through a cardboard box attempting to pop the balloon!
00:31