Skip to content

Commit 331eb53

Browse files
SteffenDEAratramba
andcommitted
Mention that non stream items still require a unique ID
Closes #3707. Co-Authored-By: Arjen <[email protected]>
1 parent bb2591e commit 331eb53

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/phoenix_live_view.ex

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,9 @@ defmodule Phoenix.LiveView do
18131813
</table>
18141814
```
18151815
1816+
It is important to set a unique ID on the empty row, otherwise it cannot be tracked
1817+
in the stream container and subsequent patches will duplicate the node.
1818+
18161819
## Non-stream items in stream containers
18171820
18181821
In the section on handling the empty case, we showed how to render a message when
@@ -1821,15 +1824,17 @@ defmodule Phoenix.LiveView do
18211824
Note that for non-stream items inside a `phx-update="stream"` container, the following
18221825
needs to be considered:
18231826
1824-
1. Items can be added and updated, but not removed, even if the stream is reset.
1827+
1. Non-stream items must have a unique DOM id.
1828+
1829+
2. Items can be added and updated, but not removed, even if the stream is reset.
18251830
1826-
This means that if you try to conditionally render a non-stream item inside a stream container,
1827-
it won't be removed if it was rendered once.
1831+
This means that if you try to conditionally render a non-stream item inside a stream container,
1832+
it won't be removed if it was rendered once.
18281833
1829-
2. Items are affected by the `:at` option.
1834+
3. Items are affected by the `:at` option.
18301835
1831-
For example, when you render a non-stream item at the beginning of the stream container and then
1832-
prepend items (with `at: 0`) to the stream, the non-stream item will be pushed down.
1836+
For example, when you render a non-stream item at the beginning of the stream container and then
1837+
prepend items (with `at: 0`) to the stream, the non-stream item will be pushed down.
18331838
18341839
"""
18351840
@spec stream(

0 commit comments

Comments
 (0)