Current section: Optimistic UI 29 exercises
Problem

Form Status

Loading exercise

Transcript

00:00 It's super cool that when we create a ship that it gets created right away or at least we can show stuff. So here's our ship and here's all of that and there's that. But when I hit create, I could actually hit it again and again and again and again. I could just keep hitting it. That's not great. We're actually submitting the form over and over again.

00:18 That's why this never resolves because we just boom, boom, boom. Do it again. Do it again. So like turning that off might be a useful thing to do, preventing the user from submitting that again. And then also it could be nice to give the user some sort of message that we're in the process of creating.

00:35 And so it would be good to maybe add a disabled here. So disabled is form status. If we're pending, it's disabled potentially or at least style it differently. Maybe have the text read something different. So that's what you're going to be doing in this exercise step.

00:51 It should be pretty quick, but you do need to refactor things because the component that uses use form status can't be the same one that renders the form. So we've got to take the button, move it into a separate component, and then we can use form status to get the pending state. I'd welcome you also to console log the form status to see what other properties are in

01:11 there.