Closed jamilabreu closed 4 years ago
Further info: I have a LiveView with three child LiveComponents that are siblings.
Now noticing that lots of updated()
hook methods are triggered - even for hooks in the sibling components (none are nested).
Reproduced here: https://github.com/jamilabreu/send_update_bug
Yes, it will be called multiple times on the client, because we always remount the whole diff on the client. It is a partial update on the server though. I will clarify it in the docs. Thanks for the reproducing app!
I was wrong. It is actually a bug. :)
Sorry to maybe spam this thread. I don't know if this bug is related with problem that I have, but on the first site it looks to me like it does. Please see this post: https://elixirforum.com/t/liveview-updated-hook-problem/27607/2
On 0.6.0, this behaves as expected, but note that the updated hooks will all be called on the client because the DOM elements are replaced since you did not give the containers an ID in your components. If you give your divs an id, morphdom will patch the containers rather than replacing them, for example:
<div phx-hook="ComponentThree" id="<%= @id %>">Component Three</div>
On the server, the updated
callback is only executed for the desired component regardless. Thanks!
Environment
Actual behavior
I have a list of components with the same phx-hook, and I'm seeing that using:
triggers
updated()
on all componentsExpected behavior
I expected
updated()
to only trigger for theAppWeb.ExampleComponent
with an id of123