Skip to content

Fix useOptimistic example #7792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged

Conversation

rickhanlonii
Copy link
Member

This example was busted because the setState after await wasn't inside startTransition. Also converted it to use the action prop naming pattern, and put the form on top so it doesn't move when you submit.

Copy link
Member

@sophiebits sophiebits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the form’s on top do you wanna prepend instead of append?

@rickhanlonii
Copy link
Member Author

@sophiebits good call, fixed

@rickhanlonii rickhanlonii merged commit d6c4c0f into reactjs:main Apr 29, 2025
6 checks passed
@rickhanlonii rickhanlonii deleted the rh/fix-uo-docs branch April 29, 2025 22:07
}
return <Thread messages={messages} sendMessage={sendMessage} />;
return <Thread messages={messages} sendMessageAction={sendMessageAction} />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't really use the Action suffix convention if you do it this way because that implies that Thread wraps it in startTransition for you (which it could if you want to). That's what an Action is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

4 participants