Skip to content

Commit

Permalink
[next-ai-rsc] Prevent Infinite Loop in Stock Component useEffect (#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
RayFernando1337 authored Mar 3, 2024
1 parent 858d07f commit 209dde7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/next-ai-rsc/components/llm-stocks/stock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export function Stock({ name = 'DOGE', price = 12.34, delta = 1 }) {
};

if (history[history.length - 1]?.id === id) {
setHistory([...history.slice(0, -1), message]);
setHistory(prevHistory => [...prevHistory.slice(0, -1), message]);
} else {
setHistory([...history, message]);
setHistory(prevHistory => [...prevHistory, message]);
}
}
}, [startHighlight, endHighlight, history, id, setHistory, xToDate]);
}, [startHighlight, endHighlight]);

return (
<div className="p-4 text-green-400 border rounded-xl bg-zinc-950">
Expand Down

0 comments on commit 209dde7

Please sign in to comment.