Surface v0.12 released!
by Marlus Saraiva ・
surface releases liveview
Surface v0.12 is out!
This version introduces some breaking changes as it's mostly a preparation for v0.13.
It also deprecates a few components as their usage is no longer required/recommended.
Full changelog can be found here.
Here's a quick overview on the main changes.
Extracting Form components
The most impactful change is that all form-related components have been moved to
surface_form_helpers. That includes the <Form> component
itself and all other input controls.
The reason those components were created in the first place was to add support for scope-aware contexts to forms. Since this feature has been deprecated due to the lack of built-in support in Liveview, we strongly recommend using the new built-in <.form> component, along with Phoenix.HTML.Form and Phoenix.HTML.FormField structs. This new Liveview API is way more efficient regarding diff-tracking and should be the default way to design forms.
If you're not able to update all your forms at once, surface_form_helpers can be used as a safe fallback so you can gradually replace them. For more information on that, see Migration Guide - v0.12.
Deprecations
Components <LivePatch>, <LiveRedirect> and <Link> have been deprecated in favor of <.link>. Replacing those
components should be straitforward. In most cases all you have to do is to replace:
-
<LiveRedirect to="...">with<.link navigate="..."> -
<LivePatch to="...">with<.link patch="..."> -
<Link to="...">with<.link href="...">
For more info on <.link>, see the official Live Navigation docs.
Scope-aware Contexts
Another component that has been deprecated is <Context>, which used to be used to allow
Scope-aware contexts.
This feature has been deprecated and will be removed in v0.13 due to the lack of built-in
support for the feature in Liveview itself, which leads to inefficient diff-tracking when using it.
Global context related functions like Context.put/3 and Context.get/3, as well as data/prop's
option :from_context, will be kept and recommended as their usage don't affect diff-tracking
negatively.
Happy coding!
-marlus