hungnt03
hungnt03

Reputation: 61

Bind in blazor is delayed by 1 step

I'm sorry because my english is pretty bad. I have a problem and would love to get some help.

I'm trying to get return value from component and update it in another component. enter image description here

When component B's product selection button is pressed, the selected product will be bound to the main screen, then an item will be updated again in component A.

The weird thing is that the first time I select, nothing happens. The second time I select the product, the first item is added to component A.

Even in component A itself, when I increase or decrease the number of products, the data in component A itself gets the same error.

Here is my source code

Component A

Component B

Main Screen

Upvotes: 2

Views: 837

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273824

In index.razor you have two async void methods. Make them async Task and await them in C#.

async void runs unobserved, there is no UI update when they finish. You should never need async void in Blazor. Blazor supports async Task for eventhandlers.

Upvotes: 3

Related Questions