I think that will help you. https://laracasts.com/series/blade-component-cookbook
Component vs blade @include vs Livewire
I discover the news in Laravel 8 like the components.
I have some difficulty to understand the real utility of the components, perhaps because I already use Livewire.
I feel that it's not possible to use a component to have a similar behavior as in a Livewire component, for example by writing a select / option component with the correct id returned to the form.
I have identified three different ways to add some "component" in a view :
@include('my.component')
<x-my-component/>
@livewire('my-component')
But I still think that Livewire helps to solve many difficulties generated by a simple blade component.
What about your opinion on this subject ?
Thanks for your help to better understand this.
Vincent
This is interesting… in short from your lens,
-
@include with have access to any props on the page.
-
<x-component…> don't have access to props on the page. you can pass them in. But it actually creates some limitations but it’s the new way and there are other benefits to these components.
-
Livewire components. I wouldn’t necessarily put in the same category as the first two. I mean yes, you can use them In a component way but I wouldn’t look at them as parts, first. That said, It is advisable to use the first two inside a livewire component. I see some examples of how to use livewire, including here that break up the page into separate livewire components unnecessarily. Particularly when they must share data heavily across other components. But this is a whole separate topic. Livewire components as others have responded are reactive and securely get data from the server. I would say this is their main feature.
Please or to participate in this conversation.