Skip to content

Commit

Permalink
Update docs/tutorials/jokes.md
Browse files Browse the repository at this point in the history
Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
  • Loading branch information
machour and MichaelDeBoey committed Jan 28, 2023
1 parent 54f3443 commit 3014ae4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/tutorials/jokes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ First I want you to notice that I've passed `typeof action` to the `useActionDat

You may also notice that I return the fields as well. This is so that the form can be re-rendered with the values from the server in the event that JavaScript fails to load for some reason. That's what the `defaultValue` stuff is all about as well.

The `badRequest` helper function accepts a generic that it passes to `json`, so that type inference works, while still returning the accurate HTTP status, [`400 Bad Request`][400-bad-request], to the client. If we just used `json()` without specifying the status, that would result in a `200 OK` response, which isn't suitable since the form submission had errors.
The `badRequest` helper function will automatically infer the type of the passed data, while still returning the accurate HTTP status, [`400 Bad Request`][400-bad-request], to the client. If we just used `json()` without specifying the status, that would result in a `200 OK` response, which isn't suitable since the form submission had errors.

Another thing I want to call out is how all of this is just so nice and declarative. You don't have to think about state at all here. Your action gets some data, you process it and return a value. The component consumes the action data and renders based on that value. No managing state here. No thinking about race conditions. Nothing.

Expand Down

0 comments on commit 3014ae4

Please sign in to comment.