Stream causes rerender issue

Following a tutorial i am using a stream in a very simple manner:

<div phx-update="stream" id="data-list">
   <div :for={{id, data} <- @streams.list} id={id}>
          class={[data == @selected_data && "selected"]}
          <span class={data.status}></span>
          <%= %>
  • whenever you click on the data link it changes the selected_data to the currently clicked data item.
  • issue is - whenever selected_data is changed (whenever anyone clicks on a data to view its details) the link does not receive the changes and hence the css class is not applied to the newly clicked data item.

I think the issue is with phx-update=“stream” but do not see a solution. Any help will be much appreciated.

1 Like