Loading case detail
Concurrent asynchronous notifications can each append to the same captured message array.
--- a/src/components/Notifications.tsx +++ b/src/components/Notifications.tsx @@ -5,7 +5,7 @@ export function Notifications() { async function receive(message: string) { await Promise.resolve(); - setMessages(previous => [...previous, message]); + setMessages([...messages, message]); } return <button onClick={() => receive("new")}>{messages.length}</button>;
--- a/src/components/Notifications.tsx +++ b/src/components/Notifications.tsx @@ -5,9 +5,8 @@ async function receive(message: string) { await Promise.resolve(); - setMessages([...messages, message]); + setMessages(previous => [...previous, message]); } return <button onClick={() => receive("new")}>{messages.length}</button>; } -