docs: Add useOptimistic hook description to hooks reference page - #8571
Open
martinrebo wants to merge 1 commit into
Open
docs: Add useOptimistic hook description to hooks reference page#8571martinrebo wants to merge 1 commit into
martinrebo wants to merge 1 commit into
Conversation
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8570
📝 Description
Adds
useOptimisticto the State Hooks section of the Built-in React Hooks overview page.The hook was already documented at
/reference/react/useOptimisticand listed in the left navigation menu, but was missing from the overview page, leaving it incomplete with only 17 of the 18 hooks documented.useOptimisticis placed under State Hooks rather than Performance Hooks because its primary purpose is to manage a temporary state value during an async operation — not to optimize rendering. It works similarly touseState, holding a value that React will revert once the async action settles. The performance benefit of a snappier UI is a side effect, not the core intent.📚 Motivation
The overview page is the main entry point for developers exploring React's built-in hooks. Having
useOptimisticabsent from this page means:useOptimisticis particularly relevant in modern React apps using Server Actions and async transitions, so its visibility on the overview page is valuable for developers adopting these patterns.✅ Changes
src/content/reference/react/hooks.md— addeduseOptimisticto the State Hooks section alongsideuseStateanduseReducer.Testing
http://localhost:3000/reference/react/hooksyarn check-allwith no errorsBefore
After
🙏 Note:
There is a stale PR #8352 that proposed creating a dedicated Async Hooks section, which would be a more permanent home for
useOptimistic. This fix places it under State Hooks as the most logical interim location, and can be revisited if that proposal or a similar one moves forward.Let me know if this should be placed in a different order, section, or if there are any copy edits needed.
🙇♂️ Thanks for maintaining a great developer experience with the docs!