phoenixframework / phoenix_live_view

Rich, real-time user experiences with server-rendered HTML
https://hex.pm/packages/phoenix_live_view
MIT License
6.14k stars 919 forks source link

assigns-eex.md says you can't reassign `assigns` in `render/1` when you can #3290

Closed anagrius closed 3 months ago

anagrius commented 3 months ago

Environment

LiveView Docs v1.0.0-rc.0

Actual behavior

The docs says:

Unlike LiveView's render/1 callback, a function component can modify the assigns it receives via the assign/2, assign/3, assign_new/3, and update/3 functions. Therefore, you can assign the computed values before declaring your template.

Expected behavior

Cleanly you can:

def render(assigns) do
    assigns = assign(assigns, :foo, 123)

    ~H"""
    <%= @foo %>
    """
end

I think that should just be removed from the docs? See https://elixirforum.com/t/reassigning-assigns-in-render/64038/3 for context

SteffenDE commented 3 months ago

Related: https://github.com/phoenixframework/phoenix_live_view/pull/2887

@josevalim @alexcastano one of you can probably clarify this :)