Skip to content

Conversation

rickhanlonii
Copy link
Member

When you create a function with the action suffix, it's because you know that it's being called inside of a transition. So it doesn't really make sense to immediately wrap the body of a function named sendMessageAction with startTransition.

The reason the useOptimistic example did this is because the child Thread component was not awaiting the action prop that was passed in, but the pattern should really be that you await the action prop if you expose it. That allows the action callback to be either synchronous or asynchronous without requiring an additional startTransition to wrap the await in the action.

@rickhanlonii rickhanlonii merged commit a3e9466 into reactjs:main Apr 30, 2025
8 checks passed
@rickhanlonii rickhanlonii deleted the rh/fix-uo-docs-2 branch April 30, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants