Lesson 2
Forms Without Tears (useActionState)
Server Actions & State
The Shift: Forget onSubmit, e.preventDefault(), and creating generic isSubmitting states. React 19 handles the form lifecycle for you.
👀 Preview
User types "React 19" and hits enter. Button instantly changes to "Updating..." and disables. After 1s, it reverts, and the text "Updated to React 19" appears below.
📚 Explanation
`useActionState` manages form submission state automatically. It provides the current state, a submit action function, and a pending boolean. The form automatically disables during submission, and you can return state from the action function to show errors or success messages.
DOJO PETYour little coding companion
App.tsx
How well did you remember this?