You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using variables of for loop to bind a value in for loop body, such as i, will bind all binding values to the values of termination conditions of for loop (step count +1)
To Reproduce
step1:create the webassembly blazor default demo
step2:modify the FetchData.razor just like this
This is a known limitation on the Razor compiler. When using the i variable inside the for loop, the code in the event handler closes over the loop variable which is what is causing the issue.
There are a couple of things you can do to avoid this:
Use a foreach loop instead of a for loop as that will give you the correct semantics
Declare a temporary variable within the loop body and assign it to the value of the loop variable at the time and use the temporary variable through the code instead.
Describe the bug
Using variables of for loop to bind a value in for loop body, such as i, will bind all binding values to the values of termination conditions of for loop (step count +1)
To Reproduce
step1:create the webassembly blazor default demo
step2:modify the FetchData.razor just like this
step3: register HttpClientFactory to ServiceCollection
setp4: run server
step5: run blazor and click the remove button
Further technical details
If I define a variable "index" and assign the value of "i" to "index" in the for loop body, binding "index" it's work good
The text was updated successfully, but these errors were encountered: