Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor @key inside the component

$
0
0

I went through the docs of Blazor @key usage. But I am not sure if it works correctly in one specific case that wasn't mentioned there.

What happens if instead of this code in Page.razor:

<div>    @foreach (var person in people)    {<Details @key="person" Person="@person" />    }</div>

I would place the @key inside the Details component itself. So for Details.razor it would look like:

<div @key=@Person>    @* The rest of the component UI *@</div>@code{    [Parameter] public required Person Person { get; set; }}

because that way when I loop this component in multiple pages I dont have to always specify the @key parameter in the foreach. But does the blazor take it as the same/different scope ?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>