Skip to content

[Suggestion]: Can you add a paragraph saying useOptimistic updater function should be called in transition? #7737

Description

@gmoniava

Summary

Here:

const [optimisticState, addOptimistic] = useOptimistic(state, updateFn);

When you call updateFn without transition react gives warning:

Warning: An optimistic state update occurred outside a transition or action. To fix, move the update to an action, or wrap with startTransition.

Page

https://react.dev/reference/react/useOptimistic

Details

Can you also add this information (which is in the warning) in the docs so that it is not only as a warning in the console?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions