Summary
In this chapter, you learned how to add optimistic UI updates in Remix. You were introduced to the trade offs of optimistic UI, such as the increased complexity of client-side logic and the necessity of user feedback in case of rollbacks.
Remix’s loader
revalidation is a great starting point for synchronizing the UI with the server state. You now understand that Remix’s loader
revalidation enables us to avoid custom client-server state synchronization and lets us avoid stale states. When relying on the loader data, we get rollbacks out of the box. After each mutation, we receive the latest loader data, and our UI updates automatically.
It is still worth communicating why a mutation failed. With or without optimistic updates, it is important to display an error message to the user. For optimistic updates, it might also make sense to highlight the rolled-back data visually. Remix’s ErrorBoundary
component is a great starting point for recovering from...