useOptimistic is a React 19 hook that immediately displays an anticipated state while an asynchronous action is in progress. When the action ends, React goes back to the real state: confirmed by the server or rolled back on failure. It is used to make the interface responsive, for example for a "like".
Example
const [likes, ajouterLike] = useOptimistic(n, (cur, v) => cur + v);