Open
Description
Summary
useOptimistic demo merges state via [...state, { text: newMessage, sending:true }], which may render a same message twice in the page at the same time(although it will render correct page immediately after the incorrect one)
Page
https://react.dev/reference/react/useOptimistic
Details
merge message logic in this demo has to handle the situation:
state(array of the messages) already includes the sending message when the setMessages is called to make the page re-rendering.