Problem with life cycle hooks

I just tried to change the send_close to

  def send_close(_params, _uri, socket) do
    Enum.each(Phoenix.LiveView.Utils.get_flash(socket), fn {key, _msg} ->
      Process.send_after(self(), {:close_flash, key}, 5000)
    end)

    {:cont,
     socket
     |> Phoenix.LiveView.detach_hook(:flash, :handle_info)
     |> Phoenix.LiveView.attach_hook(:flash, :handle_info, &info/2)}
  end

It gives no error, but still the :handle_info is not added.