Lesson 8 of 30
Applying a mutation's expected result to the UI before the server confirms it makes an app feel instant — but only if failure and conflict are handled as first-class design questions, not afterthoughts.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
Which action is the stronger candidate for a fully optimistic UI update?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
An optimistic update applies a mutation's expected result to the UI immediately, before the server has actually confirmed anything happened. A "like" button fills in the moment it's tapped; a posted comment appears in the list right away. The real network round-trip might take a few hundred milliseconds, but the user never sees that wait — the app feels instant.
That speed is bought with real complexity, and a strong design answer treats both halves of it as first-class:
Tapping "like" on a post is a textbook case for optimism: the action is low-stakes, instantly and cheaply reversible, and the failure mode (a like doesn't actually register) is minor and easy to signal. The button fills in immediately; if the server later rejects it, unfilling it and showing a small "couldn't save" toast is a completely acceptable failure story.
Submitting a payment is the opposite case. Showing "payment successful" before the server has actually confirmed the charge is a serious correctness risk — if it fails, the user has already been told something false, possibly acted on that false belief (closed the tab, told someone else), and unwinding that is far worse than a brief loading spinner would have been. The right design here is the plain, honest one: show a pending state, wait for real confirmation, then show success or failure based on what actually happened.
"Would you use an optimistic update here, and what happens if it fails?" tests real judgment, not just implementation knowledge — the strongest answers explicitly weigh stakes and reversibility per action rather than treating optimism as a blanket rule to apply everywhere or nowhere.