Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Nested Components and Their "Bug"

Premium
2 min read

You can include one component into another component in Livewire. Let's imagine we have one component for listing comments, inside it, we have a component to show a comment. So each comment is a Livewire component. There is one crucial aspect to know when adding a nested component.

nested comments component


So we have a Livewire component, CommentsList, where we get the comments, order them and do other needed tasks. Then in the Blade, we show them like so:

resources/views/livewire/comments-list.blade.php:

<div>
@foreach ($comments as $comment)
<livewire:comment-show :$comment wire:key="{{ $comment->id }}" />
@endforeach
</div>

Nothing particular here in the Blade file. The only thing Livewire says...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

A
AlexSteele ✓ Link copied!

would it be possible to show the render functions for both the commentsshow and commentslist?

N
Nerijus ✓ Link copied!

But it is shown

RB
Rajesh Budhathoki ✓ Link copied!

As a beginner, I encountered some challenges while taking this course. I had hoped to gain proficiency in Livewire after making several attempts to learn it properly in the past. While I understand that this course is intended for advanced users, the term 'Scratch' suggested to me that it would cover the topic comprehensively, from the ground up.

I noticed that the course seemed to overlook the concept of routing, which left me somewhat confused. Additionally, I encountered an issue where my initial Livewire components did not load correctly. I acknowledge that it can be challenging to convey all the details in a text-based course, but including a few lines of code or clearer instructions for beginners to get started smoothly would have been greatly appreciated.

Furthermore, the source code provided at the end of the course appeared somewhat perplexing to me. It would have been beneficial if there were more explanatory comments or annotations to enhance understanding.

PK
Povilas Korop ✓ Link copied!

Thanks for the comment, sad to read your impression. We received a few similar comments and already filled in the course content with mentions of routing and links to specific docs about Breeze or something that was related.

I personally react to most of the comments if there's something unclear in the lesson or can be improved.

Indeed, I agree, at times, we assumed too much knowledge from students without explaining it deeper. Lesson learned for the future courses.

As for repository, this whole course was actually a bunch of separate experiments showing Livewire features, so we didn't even make attempts to save it all as a single repository with all the history of changes, so we ended up publishing just the latest version of what we had, after all these experiments.

EJ
emerald junn Mendoza ✓ Link copied!

Hi Povillas, What lesson number can I see that the parent have to two child components and the child components communicating with each other? Thanks in advance for the reply.

N
Nerijus ✓ Link copied!

Use livewire events to communicate between two child components

HM
Hossam Mohamed ✓ Link copied!

Excellent course, thanks

CL
Caribation Labs ✓ Link copied!

I have completed this course while commuting to work and now am confident enough to offer the skill to my customers. The course is almost a reference at work! Much more effective than yt videos. Thank you.

Improvement suggestion: make a filter to the search function limiting the results to the current course only.

PK
Povilas Korop ✓ Link copied!

Glad this course helps! Interesting suggestion: what would be the example of a search query for the current course? I'm thinking to change how search works in general on LaravelDaily, cause it's not that convenient at the moment.

CL
Caribation Labs ✓ Link copied!

I meant full text serach of the lessons. When one wants to go back to something learnt und half-forgotten

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.