useOptimistic: React's official hook for optimistic updates inside an Action. Its setter must be called inside an Action. Calling it outside one produces a warning and shows the optimistic state only briefly.- If a project already uses TanStack Query, keep the existing
onMutateapproach. ReconsideruseOptimisticlater if the architecture moves toward Server Actions and form Actions.