1
0

Livewire\Exceptions\CorruptComponentPayloadException: Livewire encountered corrupt data when trying to hydrate the [abcdefg.index] component. Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests.

Last updated at Posted at 2024-03-13

超悩まされていたこのエラー

Livewire\Exceptions\CorruptComponentPayloadException: Livewire encountered corrupt data when trying to hydrate the [abcdefg.index] component. 
Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests. in file hijk.php on line 21

何をやってもエラーになるので対処できずになやんでいたが、
どうもJavascriptで扱える整数を超えている値を扱った場合、出る様子。

例えばこんな感じのコード。

    public function mount()
    {
        $this->datalist[2902364376262391407]="AAAAA";
        $this->datalist[2902464817685127830]="BBBBB";
        $this->datalist[2902672707216567430]="CCCCC";
        $this->datalist[1102264376262391407]="DDDDD";
    }

livewire view(blade)

<select wire:model="selectid" class="m-0 pl-1 pr-4 pt-0 pb-0">
    <option value="0"></option>
    @foreach($datalist as $key=>$data)
        <option value="{{$key}}">{{$data}}</option>
    @endforeach
</select>

Livewireだとselectを変更しただけでサーバに問い合わせするが、
option valueで扱った値があまりにも大きいので、サーバに渡したとき多分壊れた値が渡され、
サーバで不一致となりパンクする様子。
どうしても大きい値(Number.MAX_SAFE_INTEGERより大きい)のVALUE値を扱いたい場合は
文字列化してしまえばなんとかなるっぽい。

    public function mount()
    {
        $this->datalist["KEY"."2902364376262391407"]="AAAAA";
        $this->datalist["KEY"."2902464817685127830"]="BBBBB";
        $this->datalist["KEY"."2902672707216567430"]="CCCCC";
        $this->datalist["KEY"."1102264376262391407"]="DDDDD";
    }

これ、気がつける普通?

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0