#Very weird layout extend issue with first component being repeated

3 messages · Page 1 of 1 (latest)

valid jay
#

This is my first time using templates with @extend, the issue can be seen in the image, for some context, the first component (<x-countdown/>) is being repeated as many times as there are components that are extending the base blade file (I have 5 components in total, they are listen below where I show how I display them, and so I guess it takes first component and repeats it, I tried changing up the order, let's say discord one, and it would repeat discord 5 times).

Also for clarification, the timer would also be repeated 5 times, but I use jQuery for that so it just doesn't show up cause it's lookign for the first element.

This is how I define custom components

Blade::component('countdown', Countdown::class);
Blade::component('games', Games::class);
Blade::component('teams', Teams::class);
Blade::component('info', Info::class);
Blade::component('discord', Discord::class);

And this is how I try to display those components, I should also mention that all of this is wrapped inside another custom component <x-main></x-main>

<x-countdown/>
<x-info/>
<x-teams/>
<x-games/>
<x-discord/>

This is my layout file (base.blade.php)

<div class="section wave @yield('wave')">
    <div class="container">
        @yield('content')
    </div>
</div>

And this is how I extend that layout, it's the same on other ones too (wave is unique in every file)

@extends('components.main.base')
@section('wave', 'wave1')
@section('content')
  some content
@endsection

It's kinda funny when I try to use something new and an issue pops out that I can't resolve
I'm using Laravel 11.X and I'm in debug mode.
What I have tried is just using pure PHP but the results are the same

@php
  echo app()->make(App\View\Components\Main\Countdown::class)->render();
  echo app()->make(App\View\Components\Main\Info::class)->render();
  echo app()->make(App\View\Components\Main\Teams::class)->render();
  echo app()->make(App\View\Components\Main\Games::class)->render();
  echo app()->make(App\View\Components\Main\Discord::class)->render();
@endphp

And yes every render() has a different view

Or is this not how extending compoentns work? what is goign on here? my nerd mind is saying that an IF statement fails somewhere and it just persists first component's view and keeps repeating it.

#

some additional info

when I tried using @php variant, it required me to specify variables in render's view() method, otherwise it would error because it doesn't see variables in the view class, so the view does get compiled (because it requires variables and it says they are missing), but it's still showing only the first view

valid jay
#

I finally manager to fix the issue