Lesson 4
The Optimistic UI (useOptimistic)
Instant Gratification
The Shift: Users hate waiting. Even if the server takes 2 seconds, show the change instantly.
👀 Preview
User types "Hello" and hits Send. Instantly: "Hello (Sending...)" appears in the list (greyed out). 2 Seconds Later: The "(Sending...)" tag vanishes as the real server data arrives.
📚 Explanation
`useOptimistic` allows you to show optimistic updates immediately while the actual server request is in progress. If the server fails, React automatically rolls back the optimistic update. This provides instant feedback to users.
App.tsx
How well did you remember this?