phoenix heex does not see a variable in a loop

133 views Asked by At

I'm new to Elixir and Phoenix, and I expect to get stuck, but this really surprises me. I'm fighting with the heex templating system. This is the part that I'm stuck at now:

<div id="issues">
  <%= for issue <- @issues do %>
    <.live_component module={ColifeWeb.IssueLive.IssueComponent} id={@issue.id} issue={@issue}  />
  <% end %>
</div>

Elixir says: variable "issue" is unused (if the variable is not meant to be used, prefix it with an underscore). But it's used! I can see it! It's used twice in fact! What's going on here? This can't be because it's used in an argument. That would make no sense.

1

There are 1 answers

0
Nikita Naumenko On

because issue is not an instance var, you could just write issue, or you can use :for inside tag e.g

<div id="issues" :for={issue <- @issues}>
    <.live_component module={ColifeWeb.IssueLive.IssueComponent} id={issue.id} issue={issue}  />
</div>