After I update to the most recent version, my event of opening a modal is no longer responding, it gives me the error " : flash is a reserved assign by LiveView and it cannot be set directly. Use the appropriate flash functions instead". Is anyone having the same problem? If yes, help me to solve ![]()
I’m already using put_flash in my occurrences, this is the weird thing ![]()
For example, this is my event called the modal. Before the Live View update, it was working properly, but now he doesn’t want to respond anymore.
def handle_event("open_modal", %{"modal_btn_id" => modal_btn_id}, socket) do
contato = Entities.get_contato!(modal_btn_id)
{:noreply,
push_patch(
socket,
to: Routes.live_path(socket, BoardLive, socket.assigns.slug, contato.slug),
replace: false
)}
end
On what LiveView version were you before the upgrade?
Check if you are re-assigning the assigns from the socket (which would have the :flash in it) anywhere in the code. In this case search for occurrences like this: assign(socket, assigns) .
I was using liveview 0.8.1.
When I check the output of my socket that is being fixed in “def mount” it returns a flash: %{}, like this:
Phoenix.LiveView.Socket <
assigns:% {flash:% {}, live_action: nil, live_module: FluxoIdealWeb.BoardLive},
changed:% {},
...
>
When I click to open the modal, the flash error indicates that it is occurring in this line of my code.
{:ok, assign(socket, Map.merge(@defaults, assigns))}
def render(assigns) do
BoardView.render("modal.html", assigns)
end
def mount(params, _session, socket) do
{:ok, socket}
end
def update(
%{
id: id,
tag_actions_y: tag_actions_y,
tag_actions_x: tag_actions_x,
tags: tags,
all_tags: all_tags,
dashboard: dashboard,
format_date_now_string: format_date_now_string
} = assigns,
socket
) do
{:ok, assign(socket, Map.merge(@defaults, assigns))}
end
I found the error, I was passing a @flash as reference for my ModalComponent, now everything is working
. Thank you !!






















