Question · JavaScript and React course · Module 9: Modern React Hooks

useOptimistic - Rollback on Error

What happens with an optimistic UI update (useOptimistic) when the server request returns an error?

Answer options

  • The optimistic value is overwritten by the actual state, reverting the change in the UI
  • The error is ignored and the optimistic value remains permanently
  • The entire application automatically reloads
  • React throws an exception that must be handled by an Error Boundary

You can check the correct answer by solving this task in the CodeWorlds game.