F
Filament7mo ago
Gush

How to work with State as a array?

<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<input type="number" x-model="state.0" />
<input type="number" x-model="state.1" />
</div>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<input type="number" x-model="state.0" />
<input type="number" x-model="state.1" />
</div>
</x-dynamic-component>
No description
Solution:
Did you pass an empty array as the initial state?
Jump to solution
4 Replies
slamx_
slamx_7mo ago
Did you try x-model="state[0]" ?
Gush
GushOP7mo ago
yeah gives null too
Solution
Dennis Koch
Dennis Koch7mo ago
Did you pass an empty array as the initial state?
Gush
GushOP7mo ago
just did
x-init="state = [];"
x-init="state = [];"
5 minutes ago, crazy how after a full morning it was as simple as this
Want results from more Discord servers?
Add your server