1 min read

Use React 19 form features to refactor a Newsletter Subscribe form

React 19 brings a lot of new improvements to how we use forms.
Practice using the new useActionState hook by refactoring a "Newsletter Subscribe" form. You'd be surprised how much code you end up removing!

Fork the CodeSandbox and try it out:
https://codesandbox.io/p/sandbox/pxxhp3

Here are a few things to pay attention to:

  • how do you now submit the form?
  • how do you handle the error and success states?
  • how do you clear the form values after a successful submission?

Did you notice any difference? What's your favourite part about the new approach?
When you're ready to check your work, take a look at this article, highlighting all the new features.