ux icon indicating copy to clipboard operation
ux copied to clipboard

[LiveComponent] Use deferred live components in cached pages

Open momocode-de opened this issue 1 year ago • 2 comments

I had the idea to provide certain pages with an HTTP cache and if a certain part of these pages should not be cached, to make a deferred live component out of this part. This has worked quite well so far, but now I have encountered the first problem: The PreMount and PostMount hooks of the component are only called up if the page does not come from the cache. This leads to problems with the ComponentWithFormTrait, for example, as it uses the PostMount hook to call the initializeForm function. If the function is not called, it can lead to errors or incorrect data in the form.

My first question is, what do you generally think of the idea of using the HTTP cache and only excluding certain parts of the cache by making them deferred live components?

And the second question, if there are no other points against it, would be whether anyone has an idea of how to solve this with the PreMount and PostMount Hooks.

momocode-de avatar Mar 29 '24 11:03 momocode-de

Nest a your component into a defered one ?

smnandre avatar Mar 29 '24 13:03 smnandre

Nest a your component into a defered one ?

Good idea, thank you!

momocode-de avatar Mar 29 '24 16:03 momocode-de