` instances are preserved and re-ordered in the UI.
+
+In some scenarios, use of `@key` minimizes the complexity of rerendering and avoids potential issues with stateful parts of the DOM changing, such as focus position.
+
+> [!IMPORTANT]
+> Keys are local to each container element or component. Keys are *not* compared globally across the document.
+
+### When to use @key
+
+Typically, it makes sense to use `@key` whenever a list is rendered (for example, in a `@foreach` block) and a suitable value exists to define the `@key`.
+
+You can also use `@key` to prevent Blazor from preserving an element or component subtree when an object changes:
+
+```cshtml
+
+ ... content that depends on @currentPerson ...
+
+```
+
+If `@currentPerson` changes, the `@key` attribute directive forces Blazor to discard the entire `` and its descendants and rebuild the subtree within the UI with new elements and components. This can be useful if you need to guarantee that no UI state is preserved when `@currentPerson` changes.
+
+### When not to use @key
+
+There's a performance cost when diffing with `@key`. The performance cost isn't large, but only specify `@key` if controlling the element or component preservation rules benefit the app.
+
+Even if `@key` isn't used, Blazor preserves child element and component instances as much as possible. The only advantage to using `@key` is control over *how* model instances are mapped to the preserved component instances, instead of the diffing algorithm selecting the mapping.
+
+### What values to use for @key
+
+Generally, it makes sense to supply one of the following kinds of value for `@key`:
+
+* Model object instances (for example, a `Person` instance as in the earlier example). This ensures preservation based on object reference equality.
+* Unique identifiers (for example, primary key values of type `int`, `string`, or `Guid`).
+
+Avoid supplying a value that can clash unexpectedly. If `@key="@someObject.GetHashCode()"` is supplied, unexpected clashes may occur because the hash codes of unrelated objects can be the same. If clashing `@key` values are requested within the same parent, the `@key` values won't be honored.
+
## Lifecycle methods
`OnInitAsync` and `OnInit` execute code to initialize the component. To perform an asynchronous operation, use `OnInitAsync` and the `await` keyword on the operation: