react.dev
react.dev copied to clipboard
docs(useFormState): Add validation (client & server) example
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
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! 🙌