Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit d7377ab

Browse files
committed
add docs
1 parent db881d9 commit d7377ab

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,22 @@ class ShowContact extends Component
119119
}
120120
```
121121

122-
The [Official Livewire documentation](https://livewire.laravel.com/docs/components#rendering-components)
122+
The [Official Livewire documentation](https://livewire.laravel.com/docs/components#rendering-components) provides more information.
123+
124+
### Keying Components
125+
Livewire components are automatically keyed by default. If you want to manually key a component, you can use the `key` attribute.
126+
```html
127+
<!-- If using Antlers -->
128+
{{ contacts }}
129+
{{ livewire:your-component-name :key="id" }}
130+
{{ /contacts }}
131+
132+
<!-- If using Blade -->
133+
@foreach ($contacts as $contact)
134+
<livewire:your-component-name :key="$contact->id" />
135+
@endforeach
136+
```
137+
The [Official Livewire documentation](https://livewire.laravel.com/docs/components#adding-wirekey-to-foreach-loops) provides more information.
123138

124139
### Multi-Site
125140
When using Livewire in a Multi-Site context, the current site gets lost between requests. There is a trait (`\Jonassiewertsen\Livewire\RestoreCurrentSite`) to solve that. Just include it in your component and use `Site::current()` as you normally do.

0 commit comments

Comments
 (0)