Skip to content

[LiveComponent] LiveProps values at template rendering #1765

@fGuix

Description

@fGuix

Hi,

I'm using live component in multiple projects and I face now a case that confuses me.
In my case, I have some pagination values (first, last, next, previous) for a list (my component) of elements.
The initial value defined in my component:

#[LiveProp]
public int $currentPage = 1;
#[LiveProp]
public ?int $first = null;
#[LiveProp]
public ?int $previous = null;
#[LiveProp]
public ?int $next = null;
#[LiveProp]
public ?int $last = null;

I have a method that changes those values in component init (thanks to ExposeInTemplate)

  #[ExposeInTemplate]
  public function initLessons(): void
  {
    ... // adapting values
  }

Now, take a look at this dump I triggered in the component template:
Capture d’écran 2024-04-22 à 12 38 34

We can see the values accessed through 'this' have been updated but not the values at the root ("liveprops" ?).

Is it an expected behaviour ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions