Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
anagrius opened this issue Jun 7, 2024 · 1 comment
Closed

Comments

@anagrius
Copy link

anagrius commented Jun 7, 2024

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
Copy link
Collaborator

Related: #2887

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants