I have two components Posts and Post, Posts show the posts and by clicking the image I want to show the data of clicked post in another component.
Posts class and component down below:
Component View:
<div class="post" x-data="{open:false}">
  @foreach($posts as $post)
    <div>
      <h1>{{ $post->name }}</h1>
      <h3>{{ $post->body }}</h3>
      <img @click="open = !open" wire:click="showPost({{ $post->id }})" src="{{ $post->image }}" alt="">
    </div>
  @endforeach
<livewireL:post>
    </div>
Component Class:
class Posts extends Component
{
  public $posts, $post;
  public function mount(){
    $this->posts = Post::all();
  }
  public function showPost($id){
    $post = Post::find($id);
    $this->post = $post;
  }
    public function render()
    {
        return view('livewire.posts');
    }
}
and this is the Post component and class that I want to show the clicked data in this component, I have tried $emit and many as documentation but no result.
Component view which I want to render that data:
<div x-show="open">
  <h1>{{ $post->name }}</h1>
  <h3>{{ $post->body }}</h3>
  <img src="{{ $post->image }}">
</div>
Class which I want to pass data:
class Post extends Component
{
  public $post;
  public function mount($id)
  {
    $this->post = \App\Post::find($id);
  }
    public function render()
    {
        return view('livewire.post');
    }
}
 
     
    