Access to @socket in a Surface.Component

Surface 0.6 only implicitly pass __context__ and __surface__, not socket anymore. My solution to this is to use the other form of the route helper: Routes.page_path(Endpoint, :index) in all surface templates, and I need to alias the Endpoint module, of course.

I kinda sense the rationale behind this change: The component now can be used in a dead view, where there is no socket. Nevertheless, this is a breaking change and it should better be documented in a upgrade guide sort of thing.

BTW: if you need to call the render/1 function directly for some reason, now you also need to explicitly pass __context__ and __surface__:

render(%{YOUR_ASSIGNS: YOUR_VALUES, __context__: @__context__, __surface__: @__surface__})
2 Likes