Loading tutorials
action prop. When the user submits the form, React calls your function with the form's data. This chapter covers that mechanism and what React does around it. It is the base for useActionState, which later chapters build on it.5 min readuseState, async/await, and the basics of useTransition. It explains the mechanism under useActionState: every action runs inside a transition. Knowing this explains where isPending comes from. It also explains why the dispatcher needs startTransition outsi4 min readuseActionState: what you pass in and what you get back. It assumes you know React function components, useState, the browser FormData API, and async functions. It also assumes you are on React 19 or later, where the hook is exported from react.5 min readuseState, the browser FormData API, and async/await. It also assumes you have seen useActionState called with an action and an initial state. The focus here is the function you pass as the first argument: what it receives, what it5 min readuseState, the HTML FormData API, and async functions. It also assumes you have seen the basic useActionState call: const [state, formAction, isPending] = useActionState(action, initialState).5 min readuseActionState returns, isPending, and how to use it to give users feedback while a submission is running. It assumes you can write a basic action function with useActionState (previous state and FormData in, next state out). It also assumes you know that 6 min readuseState, the browser FormData API, and async functions. It also assumes you have seen the basic useActionState shape: an action that receives the previous state and a FormData, and a form wired with action={formAction}.5 min readuseActionState lets you restore the user's input, and which field types need extra care. It assumes you can wr6 min readuseState, have used useActionState with a form action, and understand that React 19 runs form actions inside transitions. You should also be comfortable reading FormData in an async function.4 min readuseActionState to a form through the action prop. This chapter covers the other way to run the same action: calling the returned dispatcher yourself from a click handler, an effect, or any other code. It assumes you know useState, event handlers, and the signature `u4 min readuseActionState returns [state, dispatch, isPending], and that an action function receives (prevState, payload). It also assumes you know that React runs actions inside transitions. Here you will see what happens when dispatch is called again before the previ6 min readuseActionState form: an action that takes (prevState, formData), a state object, and a form with action={formAction}. It also assumes you know what a React component is on the server versus the client. Server functions need a framework or bundler that5 min readuseActionState passes the previous state and FormData to an action, and how isPending works. You should also be comfortable with startTransition and with returning errors as state instead of throwing them.6 min readuseActionState form and know the basics from earlier chapters: the action receives (previousState, formData), the hook returns [state, formAction, isPending], and React resets uncontrolled fields after an action finishes. Here you will learn the mistakes th5 min read