Exploring useActionState

November 14th, 2024//Ep. 200

Sam and Ryan talk about React 19's useActionState hook. They discuss how adding async functions to a plain React app introduces lots of in-between states that developers must grapple with, and how useActionState allows React to collapse and eliminate these states, bringing the simplicity of React's sync mental model to our async code.

Timestamps

  • Intro
  • How React normally eliminates state in synchronous apps
  • How useActionState lets React eliminate state in asynchronous apps
  • Why you shouldn't just pass server actions into useActionState
  • TCP/IP and UDP analogy
  • Thinking of useActionState like enqueue
  • Why the term "reducer" is too loaded for best understanding useActionState
  • How useActionState helps you build a Todo app that stays responsive during pending actions