mrfrenchfries
Hello,
We’re trying to slowly move away from Surface into using regular Phoenix components (HEEX).
However we wish to still be able to use some of the surface components we already have. Is there a way to do that?
I tried calling it as <.MySurfaceComponent.render /> from a Phoenix.Component, which works for simple surface components, but when we have more complex components, it throws an error.
For example this:
defmodule MyAppWeb.Components.TestComponent do
use Phoenix.Component
alias MyAppWeb.Surface.TestSurfaceComponent
def test_component(assigns) do
~H"""
<div>
<div>lv_component</div>
<.another_component />
<TestSurfaceComponent.render myprop="myprop" />
</div>
"""
end
def another_component(assigns) do
~H"""
<div>
another_component
</div>
"""
end
end
defmodule MyAppWeb.Surface.AnotherSurfaceComponent do
use Surface.Component
def render(assigns) do
~F"""
<div>another surface component</div>
"""
end
end
defmodule MyAppWeb.Surface.TestSurfaceComponent do
use Surface.Component
alias MyAppWeb.Surface.AnotherSurfaceComponent
prop myprop, :string
def render(assigns) do
~F"""
<div>
<div>surface_component {@myprop}</div>
<AnotherSurfaceComponent />
</div>
"""
end
end
Crashes with:
[error] GenServer #PID<0.1365.0> terminating
** (KeyError) key :__context__ not found in: %{__changed__: nil, __caller_scope_id__: nil, myprop: "myprop"}
(my_app 0.1.0) lib/my_app_web/components/test_component.ex:37: anonymous fn/2 in MyAppWeb.Surface.TestSurfaceComponent."render (overridable 1)"/1
(my_app 0.1.0) /Users/ricardo/XUKU/my_app/lib/my_app_web/components/test_component.ex:10: MyAppWeb.Components.TestComponent.test_component/1
(elixir 1.15.2) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:384: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:538: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
(elixir 1.15.2) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:384: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:136: Phoenix.LiveView.Diff.render/3
(phoenix_live_view 0.19.3) lib/phoenix_live_view/static.ex:252: Phoenix.LiveView.Static.to_rendered_content_tag/4
(phoenix_live_view 0.19.3) lib/phoenix_live_view/static.ex:135: Phoenix.LiveView.Static.render/3
(phoenix_live_view 0.19.3) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.6) lib/phoenix/router.ex:430: Phoenix.Router.__call__/5
(my_app 0.1.0) deps/plug/lib/plug/error_handler.ex:80: MyAppWeb.Router.call/2
(my_app 0.1.0) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2
(my_app 0.1.0) deps/plug/lib/plug/debugger.ex:136: MyAppWeb.Endpoint."call (overridable 3)"/2
(my_app 0.1.0) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2
(phoenix 1.7.6) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
(bandit 1.0.0-pre.10) lib/bandit/pipeline.ex:116: Bandit.Pipeline.call_plug/2
Last message: {:continue, :handle_connection}
State: {%ThousandIsland.Socket{socket: #Port<0.60>, transport_module: ThousandIsland.Transports.TCP, read_timeout: 60000, span: %ThousandIsland.Telemetry{span_name: :connection, telemetry_span_context: #Reference<0.3603920085.2461532163.4417>, start_time: -576460726155188000, start_metadata: %{remote_port: 58973, remote_address: {127, 0, 0, 1}, telemetry_span_context: #Reference<0.3603920085.2461532163.4417>, parent_telemetry_span_context: #Reference<0.3603920085.2461270018.260616>}}}, %{opts: %{websocket: [], http_1: [], http_2: []}, plug: {Phoenix.Endpoint.SyncCodeReloadPlug, {MyAppWeb.Endpoint, []}}, handler_module: Bandit.InitialHandler, http_1_enabled: true, http_2_enabled: true, websocket_enabled: true}}}
Trending in Questions
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Background
When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error:
* assembling mark...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #security
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cmo