I am getting this error in my LiveHelpers file: “undefined function live_component/2” because live_component USED to take 2 arguments and now it only takes 1.
The new Phoenix.Component defines live_component with 1 argument as:
def live_component(assigns)
live_component is being used in MyAppWeb.LiveHelpers as shown below. I didn’t write this code. This was auto-generated when I first started using LiveView 3 years ago. And it’s now breaking with this update.
def live_modal(component, opts) do
path = Keyword.fetch!(opts, :return_to)
modal_opts = [id: :modal, return_to: path, component: component, opts: opts]
live_component(MyAppWeb.ModalComponent, modal_opts)
end
MyAppWeb.LiveHelpers used to import Phoenix.LiveView.Helpers:
@doc deprecated: "Use .live_component (live_component/1) instead"
defmacro live_component(component, assigns, do_block \\ []) do
if is_assign?(:socket, component) do
IO.warn(
"passing the @socket to live_component is no longer necessary, " <>
"please remove the socket argument",
Macro.Env.stacktrace(__CALLER__)
)
end
...
I’m confused. live_component used to take 2 arguments and now it only takes 1. How am I supposed to make old versions of the live_component function work with only 1 argument??? Do I just put all of the arguments into assigns?