You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble getting phoenix_flash from my conn session into LiveView assigns after the recent commit that automatically loads session and csrf tokens.
Previously to commit 08bf17 it was working great like this:
On disconnected mount the flash message is assigned and properly rendered for a split second. Unfortunately, after the LV connects and mount is called again the "phoenix_flash" is already cleared and no longer appears in the session which causes it to disappear from the render.
I thought using assign_new would work since once the assign is set (on disconnected render) it would not be overwritten on the live connect but it appears the socket assigns do not persist between renders... I guess because the true "socket" doesn't exist at that point.
I know the usual pattern is rendering flash in your layout (which would work) but I can't do that because I need the message rendered in the middle of a LV not above it.
The text was updated successfully, but these errors were encountered:
we render the page and we show the flash message, the use of the flash message makes it be removed from the session
then we connect to LiveView with the new session, where flash_message was already discarded
I am not sure what is the best fix here. But we will need to eventually solve it because we are planning to move layouts to LiveViews too. Maybe we will make any current flash part of the live view session and handle it automatically for you.
And you are correct in regards to assign_new. It is not shared between connections (the disconnected and connected render). It is mostly used to pass information from parent to child.
Environment
I'm having trouble getting phoenix_flash from my conn session into LiveView assigns after the recent commit that automatically loads session and csrf tokens.
Previously to commit 08bf17 it was working great like this:
Now the conn session is automatically loaded so the code looks like this:
On disconnected mount the flash message is assigned and properly rendered for a split second. Unfortunately, after the LV connects and mount is called again the "phoenix_flash" is already cleared and no longer appears in the session which causes it to disappear from the render.
I thought using
assign_new
would work since once the assign is set (on disconnected render) it would not be overwritten on the live connect but it appears the socket assigns do not persist between renders... I guess because the true "socket" doesn't exist at that point.I know the usual pattern is rendering flash in your layout (which would work) but I can't do that because I need the message rendered in the middle of a LV not above it.
The text was updated successfully, but these errors were encountered: