Livewire encountered corrupt data when trying to hydrate the *file_name* component

Hello everyone, i have this problem:

Livewire encountered corrupt data when trying to hydrate the [news-comments] component. Ensure that the [name, id, data] of the Livewire component wasn’t tampered with between requests.

Code Controller:

class NewsComments extends Component
{
public $text;
protected $comments;

public function render(){
	$this->comments = \App\Comments_news::
    	join('users', 'comments_news.user_id', '=', 'users.id')
        ->join('news', 'comments_news.news_id', '=', 'news.id')
        ->select('comments_news.txt','comments_news.created_at','users.name','users.img','users.id')
        ->where('comments_news.news_id','=',$this->id)
        ->orderByDesc('comments_news.id')
        ->paginate(5);
    return view('livewire.news-comments',['comments' => $this->comments]);
}
public function mount($news){
	$this->id = $news->id;
}
public function addComment(){
	\App\Comments_news::create([
        'txt' => $this->text,
        'user_id' => Auth::id(),
        'news_id' => $this->id,
    ]);
}

}

Input “text” and button “addComment”:

<div class="row d-flex justify-content-center">
                <div class="col-md-8 col-lg-8 col-12">
                    <textarea id="addComment" name="addComment" style="width: 100%; min-height:80px;" wire:model="news_text"></textarea>
                </div>
            </div>
            <div class="row">
                <div class="col d-flex d-sm-flex d-xl-flex justify-content-end" style="margin: 0 0 15px 0;">
                    <button class="btn btn-dark text-white d-xl-flex" wire:click="addComment()" type="submit">Add Comment</button>
                </div>
            </div>

And this parameter in livewire directive:

@livewire(‘news-comments’, [‘news’=>$news])

can you specify the livewire version

Problem was in the version livewire, thanks. I used version 1.0.0, i’m update livewire and this problem solved. But now i have other problem with a wire:model, i can’t take $this->text from input, he just a void all time, and my code has not changed.

In my case the solution was to make a public property protected and pass it to the blade manually, so it was excluded from Livewire’s auto-handling under the hood.

Livewire still having problems rehydrating same property with different values

Answer is based on:

I was forced to convert a collection of a tree structure to an array for fix this error.

1 Like