<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="335914" data-post-id="335914">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Jskalc" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Jskalc/120/35876_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Jskalc
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes Jose, it seems to work. Minimal example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Mix.install([{:phoenix_playground, "~&gt; 0.1.3"}])

defmodule DemoComponent do
  use Phoenix.LiveComponent

  def render(assigns) do
    ~H"""
    &lt;li&gt;
      Count: &lt;span&gt;&lt;%= @count %&gt;&lt;/span&gt;, 
      item: &lt;%= @item.name %&gt;
    &lt;/li&gt;
    """
  end
end


defmodule DemoLive do
  use Phoenix.LiveView

  def render(assigns) do
    ~H"""
    &lt;button phx-click="randomize"&gt;randomize&lt;/button&gt;

    &lt;ul&gt;
      &lt;.live_component 
        :for={item &lt;- @items} 
        id={item.id}
        module={DemoComponent} 
        count={@count} 
        item={item} 
      /&gt;
    &lt;/ul&gt;
    """
  end

  def mount(_params, _session, socket) do
    socket = socket |&gt; assign(:count, 0) |&gt; assign(:items, random_items())
    {:ok, assign(socket, :count, 0)}
  end

  def handle_event("randomize", _params, socket) do
    {:noreply, socket |&gt; assign(:items, random_items()) |&gt; update(:count, &amp;(&amp;1 + 1))}
  end

  def random_items() do
    1..11
    |&gt; Enum.take_random(10)
    |&gt; Enum.map(&amp;%{id: &amp;1, name: "New#{&amp;1 + 1}"})
  end
end

PhoenixPlayground.start(live: DemoLive)
</code></pre>
<p>and this is a payload from the console</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/2/4/242945ea804b9307c141f55e207d8cf3c27b891a.png" data-download-href="https://forum.elixirforum.com/uploads/default/242945ea804b9307c141f55e207d8cf3c27b891a" title="image" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/2/4/242945ea804b9307c141f55e207d8cf3c27b891a_2_690x225.png" alt="image" data-base62-sha1="59TCcxsdwkAb79n0dbln0imuSr8" width="690" height="225" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/2/4/242945ea804b9307c141f55e207d8cf3c27b891a_2_690x225.png, https://forum.elixirforum.com/uploads/default/optimized/3X/2/4/242945ea804b9307c141f55e207d8cf3c27b891a_2_1035x337.png 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/2/4/242945ea804b9307c141f55e207d8cf3c27b891a_2_1380x450.png 2x" data-dominant-color="2E2E2E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1430×468 40 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>it updates only dynamic parts that changed, and it seem to reorder correctly as well. So I’d say it’s what we want when it comes to the payload size! <img src="https://forum.elixirforum.com/images/emoji/apple/rocket.png?v=15" title=":rocket:" class="emoji" alt=":rocket:" loading="lazy" width="20" height="20"></p>
<p>Just, I’d like to understand the tradeoffs. If I’m correct:</p>
<ul>
<li>it keeps the assigns separately for each live_component, possibly doubling memory consumption</li>
<li>it keeps a list of assigned IDs.</li>
</ul>
<p>It seems these are not kept in the socket but somewhere else in the process state. I’ll look how exactly they’re handled currently soon.</p>
<p>So the questions:</p>
<ul>
<li>how we could make the API more approachable? I like your suggestion of adding an attribute that will make any function component <code>live_component</code>. Probably it shouldn’t be id, though, since it might be used simply to have it in DOM. Maybe something like <code>phx-component-id</code>?</li>
<li>I know it might be a big change, but would it be possible to avoid storing assigns separately for each live_component created that way and instead rely on <code>__changed__</code> to detect what should be updated? <img src="https://forum.elixirforum.com/images/emoji/apple/thinking.png?v=15" title=":thinking:" class="emoji" alt=":thinking:" loading="lazy" width="20" height="20"> Because that’s the only thing we need old assigns for, right?</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="335914" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/32">Post #31</a>
	                </div>
	            </div>
              <div id="likers-container-335914" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="335914"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #31"></div>
  </section>
</div>
    <div class="postbit" id="336003" data-post-id="336003">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Woot!</p>
<aside class="quote no-group" data-username="Jskalc" data-post="32" data-topic="64986">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jskalc/48/35876_2.png" class="avatar"> Jskalc:</div>
<blockquote>
<p>it keeps the assigns separately for each live_component, possibly doubling memory consumption</p>
</blockquote>
</aside>
<p>It doesn’t double memory consumption per se because they would all point to the same items. The best way to think about it is that you will have a list of items, <code>[item]</code>,  and LiveComponents will keep one additional map of <code>%{id =&gt; item}</code>, but the item is the same. The extra cost here is on keeping the map (there are other costs related to LiveComponents but we may be able to optimize them for this case).</p>
<aside class="quote no-group" data-username="Jskalc" data-post="32" data-topic="64986">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jskalc/48/35876_2.png" class="avatar"> Jskalc:</div>
<blockquote>
<p>I know it might be a big change, but would it be possible to avoid storing assigns separately for each live_component created that way and instead rely on <code>__changed__</code> to detect what should be updated? <img src="https://forum.elixirforum.com/images/emoji/apple/thinking.png?v=15" title=":thinking:" class="emoji" alt=":thinking:" loading="lazy" width="20" height="20"> Because that’s the only thing we need old assigns for, right?</p>
</blockquote>
</aside>
<p>Yes, that may be possible too. It just depends on how much work we want to put into the Diff engine in order to make this work. The first step would probably be to extract the LiveComponent logic out and allow it to be replaced by this new logic for these new “components”.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336003" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/33">Post #32</a>
	                </div>
	            </div>
              <div id="likers-container-336003" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336003"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #32"></div>
  </section>
</div>
    <div class="postbit" id="336015" data-post-id="336015">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-livebook_core_team" data-username="josevalim" data-post="33" data-topic="64986">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/48/1787_2.png" class="avatar"> josevalim:</div>
<blockquote>
<p>but the item is the same</p>
</blockquote>
</aside>
<p>Does this hold true when doing send update? IIRC send flattens the term, even when sending to self(). When receiving the value you’ve got two values that while equivalent are not literally pointers to the same heap spot.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336015" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/34">Post #33</a>
	                </div>
	            </div>
              <div id="likers-container-336015" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336015"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #33"></div>
  </section>
</div>
    <div class="postbit" id="336037" data-post-id="336037">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Schultzer" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Schultzer/120/4339_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Schultzer
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That is a very good question, given live component are part of the same process and we have function component, then I don’t see why they couldn’t be married and we would avoid all the hidden costs, although they might be cheap, they are still there.<br>
For people that build complex apps that rival native apps, then performance matters!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336037" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-336037" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336037"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #34"></div>
  </section>
</div>
    <div class="postbit" id="367726" data-post-id="367726">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="steffend" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/steffend/120/20548_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  steffend
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Phoenix Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>We now have <code>:key</code> for <code>:for</code> in LiveView 1.1! <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://phoenix-live-view.hexdocs.pm/1.1.0-rc.1/changelog.html">
  <header class="source">

      <a href="https://phoenix-live-view.hexdocs.pm/1.1.0-rc.1/changelog.html" target="_blank" rel="noopener nofollow ugc">phoenix-live-view.hexdocs.pm</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://phoenix-live-view.hexdocs.pm/1.1.0-rc.1/changelog.html" target="_blank" rel="noopener nofollow ugc">Changelog for v1.1 — Phoenix LiveView v1.1.0-rc.1</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367726" data-batch-url="/posts/batch_likers">
                        8
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-367726" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367726"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="367727" data-post-id="367727">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This is a really important change, thanks for your work!</p>
<p>I saw this is based on LiveComponents internally, so I would assume the <code>:key</code> has to be a global id. But I don’t see that mentioned in the docs anywhere. Is that the case?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367727" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-367727" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367727"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #36"></div>
  </section>
</div>
    <div class="postbit" id="367728" data-post-id="367728">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="steffend" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/steffend/120/20548_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  steffend
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Phoenix Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>We automatically prefix the key with the current module, line and file, so it doesn’t have to be globally unique.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367728" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-367728" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367728"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #37"></div>
  </section>
</div>
    <div class="postbit" id="367730" data-post-id="367730">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Very cool! But wait, what happens if you do this?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def foo(assigns) do
  ~H"""
  &lt;div&gt;
    &lt;div :for={id &lt;- [1, 2, 3]} :key={id}&gt;{"Div #{id}"}&lt;/div&gt;
  &lt;div&gt;
  """
end

def bar(assigns) do
  ~H"""
  &lt;.foo /&gt;
  &lt;.foo /&gt;
  &lt;div&gt;
    &lt;%= for _i &lt;- 1..10 do %&gt;
      &lt;.foo /&gt;
    &lt;% end %&gt;
  &lt;/div&gt;
  """
end
</code></pre>
<p>Won’t they all have the same module/line? You would need the whole call stack or something, right?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367730" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-367730" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367730"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #38"></div>
  </section>
</div>
    <div class="postbit" id="367732" data-post-id="367732">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="steffend" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/steffend/120/20548_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  steffend
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Phoenix Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Well yeah, it’s best effort - so you can construct cases like this where it won’t work. You’ll get an exception in that case, but I’m not sure how common this would be. If you always render 1 2 and 3, the best diff would be to just unroll that loop manually, then everything is static <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367732" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/40">Post #39</a>
	                </div>
	            </div>
              <div id="likers-container-367732" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367732"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #39"></div>
  </section>
</div>
    <div class="postbit" id="367735" data-post-id="367735">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I was being lazy in not giving a dynamic example <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>If you had e.g. a user_list like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def user_list(assigns) do
  ~H"""
  &lt;div class="user-list"&gt;
    &lt;div :for={user &lt;- @users} id={user.id}&gt;
      &lt;.user_entry user={user} /&gt;
    &lt;div&gt;
  &lt;/div&gt;
  """
end
</code></pre>
<p>And then you had more than one on the page, with overlapping entries, like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def mount(socket) do
  socket = assign(socket, %{
    # Imagine these are loaded from the DB...
    new_users: [user1, user2, user3],
    top_users: [user2, user4, user6],
  })
end

def render(assigns) do
  ~H"""
  &lt;div&gt;
    &lt;.user_list title="Top users" users={@top_users} /&gt;
    &lt;.user_list title="New users" users={@new_users} /&gt;
  &lt;/div&gt;
  """
end
</code></pre>
<p>Now you would be in trouble, because the global ids don’t compose properly. In React the components are mounted implicitly based on the tree position (children are keyed all the way up) so they don’t have this problem. I don’t mean to harp on this in particular (this is still a big improvement!), I was mostly just curious. It would be nice if we didn’t need global ids, but they are at least forward-compatible with non-global ids so it’s something that can be kicked down the road for now.</p>
<p>If I could offer one piece of feedback, though: I worry the “implicit prefixing” trick you mention could create more confusion, since it will work <em>sometimes</em>. I think it might be better to be explicit about requiring global ids until the problem can be solved “properly” in the future.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367735" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/possible-payload-size-improvement-to-heex-list-comprehensions/64986/41">Post #40</a>
	                </div>
	            </div>
              <div id="likers-container-367735" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367735"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #40"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/64986/load_more?page=5">Load more posts (10 remaining)</a>
</div></template></turbo-stream>