All entries

    React Native Optimistic Updates with Rollback

    Show a check-in edit immediately, then reconcile it with the confirmed response or roll back the specific failed edit.

    A mobile user checks an update beside arrows that show reversal
    Conceptual pixel-art illustration.

    Show a check-in edit immediately, then reconcile it with the confirmed response or roll back the specific failed edit.

    Build the example

    Use an invented water-logging note and key the cache by day and account. Cancel stale reads before writing an optimistic value. Keep a snapshot or a mutation-scoped inverse operation, and use server-confirmed data after success. A full snapshot rollback can erase a second edit that happened later, so serialize edits for the same record or roll back by operation ID.

    Start with the check-in note “walked 20 minutes” at revision 4. Optimistically show a longer note, then have the server reject that edit with revision 5 already present. Keep the server record visible and show the user’s draft separately. This case exposes whether your implementation loses information while attempting rollback.

    Watch the failure boundary

    A successful network response can carry a server-normalized value, such as a trimmed note or a new revision. Replace the optimistic object with that value before invalidating other readers. On an ambiguous connection failure, query the server for the current record instead of assuming it rejected the write. Keep the user’s draft available for recovery.

    Verify the behavior

    Simulate a slow rejected edit followed by a successful one. The final visible record should reflect the success and remove the rejected draft. Also test a server revision conflict and a screen opened on a different account. Show pending feedback until the operation settles so the UI does not present an unconfirmed edit as durable.

    FURTHER READING

    Sources

    Technical references checked .

    END OF ENTRY / 42
    Eeshan Singh with Big Ben in London
    BEHIND THE JOURNAL

    Eeshan Singh

    I’m Eeshan Singh Pokharia, an AI Full Stack Developer and CoFounder of UltraFit360. I work across AI features, full-stack product development, and web and mobile experiences—from Figma and frontend interactions to the systems behind them.

    A successful network response can carry a server-normalized value, such as a trimmed note or a new revision. Replace the optimistic object with that value before invalidating other readers. On an ambiguous connection failure, query the server for the current record instead of assuming it rejected the write. Keep the user’s draft available for recovery.

    Meet the author
    THE CONVERSATION

    Your side of the story.