Hands-on practice for this lecture. Work through the exercises and quizzes to reinforce what you've learned.
Exercise 1 of 1
Three questions on React 19's useOptimistic β what it returns, what happens on server failure, and when optimistic UI is the right pattern.
const [optimisticMessages, addOptimisticMessage] = useOptimistic( messages, // actual state from server (state, newMsg) => [...state, newMsg] );
What does optimisticMessages contain?
What happens if the server action fails?
useOptimistic is most useful whenβ¦
0/3 answered
π‘ useOptimistic is React 19's primitive for optimistic UI. It pairs naturally with useActionState β the action runs, the optimistic state shows immediately, and React reconciles when the server responds.