React · Middle · Question 30 of 75
What is useOptimistic for?
- ✓Correct answer: Showing the expected result before the server responds
- 2Optimizing rendering by skipping unnecessary updates
- 3Preloading data that will be needed soon
Explanation
While an action is running, useOptimistic returns an optimistic version of the data (e.g. the new message is already in the list). When the action finishes, the real state is shown, and on error the optimistic value simply disappears.