react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

docs(useFormState): Add validation (client & server) example

Open bennettdams opened this issue 2 years ago • 1 comments
trafficstars

After seeing a great example from Matt Carroll, I decided to add a slightly different version for client- & server-side validation when using the useFormState hook. In the example, the form action returns different messages for different scenarios:

  • A username with less than three characters
  • The username "foo", which is reserved
  • A username with more than three characters

Here's a screen recording of the three:

https://github.com/reactjs/react.dev/assets/29319414/20e707ae-2122-4316-b3ce-5ae3514f5c76

bennettdams avatar Nov 08 '23 01:11 bennettdams

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

github-actions[bot] avatar Nov 08 '23 01:11 github-actions[bot]