React · Middle · Question 30 of 75

What is useOptimistic for?

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.

Further reading

Problem with a question

React · Middle · question 30

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz