Redirection within layout causes remount

Hey Guys,

I have a Question regarding the push_redirect function. According to the docs a push_redirect keeps the layout (v0.15.4):

live_redirect/2 and push_redirect/2 mounts a new LiveView while keeping the current layout

That implies for me that any stateful LiveComponent or LiveView defined in the Layout keeps it state after a push_redirect/live_redirect. I have defined a stateful LiveComponent in my live layout but it did not work. Every LiveComponent/View defined in the layout was remounted. Am I misunderstanding something here?
Maybe it’s because I trigger a redirect outside of the live routes?

LiveComponents or LiveViews being children of the live layout are afaik treated as children of the root liveview. Given a redirect makes the root liveview change/remount so will all the children I’d imagine.

1 Like

Thank you for the response.
Ok, then this is not about keeping LiveViews but about saving data. Thank you for the clarification!