Back to programming
programming#react#hooks#javascript

React 19 useOptimistic Explained

The new hook that makes optimistic UI trivial — with a working example.

Jane Contributor August 2, 2026 1 views

useOptimistic in React 19

Optimistic updates without state gymnastics:

const [optimisticTodos, addOptimistic] = useOptimistic(todos, (state, newTodo) => [...state, newTodo]);

async function submit(formData) {
  const todo = { id: Date.now(), text: formData.get('text') };
  addOptimistic(todo);
  await saveTodo(todo);
}

Keep reading

You may also like

Discussion (0)

No comments yet. Be the first to weigh in.

Leave a comment

Comments are reviewed before appearing.