Fetching & Displaying Data

What is the best practice for handling real-time data updates in a list or grid view?
function RealTimeList({ websocket }) {
  const [items, setItems] = useState([]);
  
  useEffect(() => {
    websocket.addEventListener('message', (event) => {
      const update = JSON.parse(event.data);
      
      setItems(current => {
        const index = current.findIndex(item => item.id === update.id);
        if (index === -1) return [...current, update];
        
        const newItems = [...current];
        newItems[index] = { ...newItems[index], ...update };
        return newItems;
      });
    });
  }, [websocket]);
Next Question (16/20)