I am getting the above error when I clicked any of the buttons. I have three buttons.
[error] GenServer #PID<0.983.0> terminating
**** (ArgumentError) invalid noreply from TodoLiveviewWeb.TodoLive.handle_event/3 callback.**
Expected one of:
** {:noreply, %Socket{}}**
Got: {:no_reply, #Phoenix.LiveView.Socket<assigns: %{flash: %{}, live_action: nil, live_module: TodoLiveviewWeb.TodoLive, todos: [%TodoLiveview.Todos.Todo{meta: #Ecto.Schema.Metadata<:loaded, “todos”>, done: false, …}, %TodoLiveview.Todos.Todo{meta: #Ecto.Schema.Metadata<:loaded, “todos”>, …}, %TodoLiveview.Todos.Todo{…}, …]}, changed: %{}, endpoint: TodoLiveviewWeb.Endpoint, id: “phx-Fgm4xWRCKF1vxgbC”, parent_pid: nil, root_pid: #PID<0.983.0>, router: nil, view: TodoLiveviewWeb.TodoLive, …>}
defmodule TodoLiveviewWeb.TodoLive do
use TodoLiveviewWeb, :live_view
require Logger
alias TodoLiveview.Todos
alias TodoLiveviewWeb.Live.TodoView
def mount(_params, _session, socket) do
{:ok, fetch_todos(socket)}
end
def render(assigns) do
TodoView.render("todos.html", assigns)
end
def handle_event("add_todo", %{"todo" => todo}, socket) do
Todos.create_todo(todo)
{:no_reply, fetch_todos(socket)}
end
def handle_event("show_all", _params, socket) do
{:no_reply, fetch_todos(socket)}
end
def handle_event("show_true", _params, socket) do
socket = socket |> assign(todos: Todos.list_todos_true())
{:no_reply, socket}
end
def handle_event("show_false", _params, socket) do
socket = socket |> assign(todos: Todos.list_todos_false())
{:no_reply, socket}
end
defp fetch_todos(socket) do
assign(socket, todos: Todos.list_todos())
end
end
<form action="#" phx-submit="add_todo">
<%= text_input :todo, :title, placeholder: "Please Enter a TODO" %>
<%= submit "Add", phx_disable_with: "Adding ...." %>
</form>
<button phx-click="show_all">All</button>
<button phx-click="show_true">True</button>
<button phx-click="show_false">False</button>
<%= for todo <- @todos do %>
<div><%= todo.title %></div>
<% end %>
Can someone give me insight on how to fix this error? Your help is greatly appreciated.