Skip to content

[Mistake]: The demo of useOptimistic may occur an incorrect rendering  #7379

Open
@felismargarita

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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions