Can someone help me I can't get the routing params when I use inline components for some reason I tried reading the docs but no luck.
My web.php
Route::get('/preview/blog/{wow}', BlogPost::class);
My BlogPost Class Component
public $wow;
public function render($wow)
{
dd($wow);
return view('livewire.blog.blog-post', compact('wow'))->layout('layouts.blog');
}
My inline component
@livewire('blog.blog-post', ['wow' => $wow])
My Answer:
In your BlogPost class component, you can access the route parameter using the $this->wow property. Here's how you can modify your code to get the route parameter:
php
class BlogPost extends Component
{
public $wow;
public function mount($wow)
{
$this->wow = $wow;
}
public function render()
{
dd($this->wow);
return view('livewire.blog.blog-post', compact('wow'));
}
}
By using the `mount` method, you can access the route parameter and assign it to the `$wow` property of the component. Then, you can use `$this->wow` to access the route parameter in your component.
Rate this post
5 of 5 based on 1835 votesComments