Closed
Description
I have noticed that if I have nested components and the parent component is included with loading: 'defer'
, the child component can no longer read URL parameters. Here is my code:
Parent Component
<?php
namespace App\Twig\Components;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;
#[AsLiveComponent]
class ParentComponent
{
use DefaultActionTrait;
}
<div {{ attributes }}>
<h1>Parent Component</h1>
{{ component('ChildComponent', {
sort: 'name'
}) }}
</div>
Child Component
<?php
namespace App\Twig\Components;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;
#[AsLiveComponent]
class ChildComponent
{
use DefaultActionTrait;
#[LiveProp(writable: true, url: true)]
public string $sort = '';
}
<div {{ attributes }}>
<h1>Child Component</h1>
{{ dump(sort) }}
</div>
Main template:
{{ component('ParentComponent', { loading: 'defer' }) }}
If I now call up my page with ?sort=foo, the value “name” is dumped instead of “foo”. If I remove the { loading: 'defer' }
from the parent component, the value “foo” is dumped. Is it possible in this scenario that the parent component remains defered and the child component can still read the URL parameters?