[LiveComponent] LiveProps values at template rendering #2920
Replies: 5 comments
-
The What is the problem you wanted to solve using this attribute initially ? |
Beta Was this translation helpful? Give feedback.
-
I'm typically using the #[ExposeInTemplate] attribute to initialize values before rendering component. In this case, it's getting the list of items and initializing the pagination values used in the frontend template. |
Beta Was this translation helpful? Give feedback.
-
Yeah but this is not the goal of the ExposeInTemplate attribute, and the documentation is pretty clear about what it does.. To be honest i'm even surprised it does not throw an error in your case, and this is something that could happen anytime.. To initialize things you would have better / stable results using the dedicated PreMount / PostMount hooks |
Beta Was this translation helpful? Give feedback.
-
ok. Thanks for the pointers. I will change accordingly and see the behavior. |
Beta Was this translation helpful? Give feedback.
-
all good, thanks for the help. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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:
I have a method that changes those values in component init (thanks to ExposeInTemplate)
Now, take a look at this dump I triggered in the component template:

We can see the values accessed through 'this' have been updated but not the values at the root ("liveprops" ?).
Is it an expected behaviour ?
Beta Was this translation helpful? Give feedback.
All reactions