Handle_event not getting called in LiveView example

I’m using. Phoenix 1.7.11 and LiveView 0.20.2.

I have this in router.ex

  use Phoenix.Router
  import Phoenix.LiveView.Router

  scope "/", AmplifyWeb do
    pipe_through :browser

    live "/temperature", ThermostatLive
  end

And this in my live view module:

defmodule AmplifyWeb.ThermostatLive do
  use Phoenix.LiveView

  def render(assigns) do
    IO.inspect "in render"
    ~H"""
    Current temperature: <%= @temperature %>°F
    <button phx-click="inc_temperature">+</button>
    """
  end

  def mount(_params, _session, socket) do
    IO.inspect "in ff"
    temperature = 70 # Let's assume a fixed temperature for now
    {:ok, assign(socket, :temperature, temperature)}
  end

  def handle_event("inc_temperature", _params, socket) do
    IO.inspect "i am here"
    {:noreply, update(socket, :temperature, &(&1 + 1))}
  end
end

The page displays fine with 70 being displayed, but clicking on the button does not do anything and handle_event is not called.

Do I have to do something else to get this working? Do I need to have any templates defined for LiveView to work

Do you still have the browser pipeline defined in router.ex?

It’s probably easiest to start with the generated code for router and AmplifyWeb.

Are there any errors or warnings in your browser devtools console?

Thank you. That was it. Really dumb mistake. Thank you.