Current section: Optimistic UI 29 exercises
Problem

Optimistic UI

Loading exercise

Transcript

00:00 So Kelly did a bunch of work for us to put together a form with a form action that will create a new ship.

00:06 So if we type in mining ship and top speed of four, and if we choose a cool ship file here, and then hit create, then after a moment, and another moment, there it is. All right, awesome.

00:23 That user experience is not good, could definitely use some optimistic UI. The fact is that, like, for sure, there's only so much that you can do because the network is not under your control. So maybe it'll be that slow, for real, you just really can't control that. But what we can't control is what we are showing the user while that is happening.

00:42 And we could show that really nice user experience, just show the ship right away, while things are happening in the background. And so that's why we're going to be using use optimistic, because if we put our optimistic UI in use state or something, those state updates aren't going to happen during the transition.

01:00 Only optimistic state updates will happen during a transition like the one in a form action. So you're going to go and make some refactorings, we're going to have to refactor our ship details, or at least add a feature to the ship details to accept an optimistic ship.

01:17 So it can display that one instead of the ship that is currently selected, various other things that you're going to be making in the emoji will guide you. But we're by the time you're done, the experience of creating a new ship is going to be a lot better. So have a good time with this one.