Introduction: The Misunderstood Hook

React 19 has introduced several powerful primitives, but perhaps none are as frequently misunderstood as useOptimistic. When developers first encounter it, the temptation is to treat it as a new, lightweight state management solution—a replacement for local useState calls when handling form submissions.

This is a mistake. If you treat useOptimistic as a general-purpose state management tool, you will encounter flickering, inconsistent UI states, and data synchronization bugs. To master this hook, you must abandon the "state manager" mental model and replace it with something more robust: the Git rebase.

The Mental Model: Thinking in Git Rebases

In Git, a rebase allows you to take your local commits and "replay" them on top of a new base branch. This is exactly how React 19 handles optimistic updates.