Evolution of Form Management in React

certificate
Recording and certification are available to Multipass and Full ticket holders only
Please login if you have one.
Rate this content
Bookmark

Learn how to handle forms in React using the latest features, such as startTransition, useTransition, useOptimistic, and useActionState, with and without React 19 server actions, alongside proper validation, error handling, and best practices.

The workshop will begin by demonstrating traditional form handling using useState and useEffect for client-side rendering. Gradually, we'll transition to using the latest React 19 features, including server-side forms and the newest hooks for managing form states and errors. By the end of the workshop, participants will understand how to create robust forms with proper validation and error handling.

Learning Goals

  • Latest React 19 Hooks — useTransition, useFormStatus, useOptimistic, useActionState, useDeferredValue
  • Server Actions
  • Revalidations
  • Server-side Validation
  • Error handling
  • Security practices

This workshop has been presented at React Summit US 2024, check out the latest edition of this React Conference.

FAQ

You will learn how to handle forms with server actions, use new React hooks like useValidation, useFormStatus, useOptimistic, and useActionState to simplify state management, and integrate validation and error handling into your React apps.

It's recommended to sit through the workshop, watch the demonstration, and later use the provided starter codebase to replicate what you learned. This allows you to focus on understanding the concepts first, before implementing them on your own.

Next.js is used because it is currently the simplest way to spin up a new React 19 application, allowing you to test out the latest React features, like React Server Components, which are not fully supported elsewhere yet.

The useFormStatus hook provides information about the status of the nearest form element, allowing you to show real-time feedback such as loading indicators or disabling buttons while a form is submitting.

The useActionState hook manages the state of a server action in React server components, allowing you to handle the lifecycle of server actions and update the client-side UI based on the server response.

You can implement optimistic UI updates in React using the useOptimistic hook, which allows you to show an immediate update to the user before the actual operation completes, enhancing the user experience during operations.

The use hook in React lets you read the value of a resource like a promise or context, simplifying the process of working with asynchronous data or context in components, especially in concurrent mode.

The useTransition hook allows you to mark some state updates as transitions, which are considered less urgent. This helps in keeping the UI responsive during large rendering updates, like switching pages or applying search filters.

The useDeferredValue hook creates a deferred version of a value, which helps in preventing expensive re-renders from blocking the UI, similar to the concept of debouncing in UI updates.

Adrian Hajdin
Adrian Hajdin
72 min
05 Dec, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Welcome to the evolution of form management in React. Learn how to build forms using the latest React hooks. Handle forms with server actions, use validation, form status, optimistic, and action state. In this course, we'll turn the basic form into three different forms, including a server form that works without client-side JavaScript. Use the useFormStatus hook to provide real-time feedback about form submission status. The useActionState hook helps manage the state of a server action in React server components. The useOptimistic hook enables the creation of optimistic UIs. The useTransition hook distinguishes between urgent and non-urgent state updates. The useDeferredValue hook defers updating a part of the UI to keep it responsive during expensive updates. Practice and experiment to learn these concepts.
Video transcription and chapters available for users with access.

Watch more workshops on topic

React Hooks Tips Only the Pros Know
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.
State Management in React with Context and Hooks
React Summit Remote Edition 2021React Summit Remote Edition 2021
71 min
State Management in React with Context and Hooks
WorkshopFree
Roy Derks
Roy Derks
A lot has changed in the world of state management in React the last few years. Where Redux used to be the main library for this, the introduction of the React Context and Hook APIs has shaken things up. No longer do you need external libraries to handle both component and global state in your applications. In this workshop you'll learn the different approaches to state management in the post-Redux era of React, all based on Hooks! And as a bonus, we'll explore two upcoming state management libraries in the React ecosystem.
Mastering React Server Components and Server Actions in React 19
React Advanced 2024React Advanced 2024
160 min
Mastering React Server Components and Server Actions in React 19
Workshop
Maurice de Beijer
Maurice de Beijer
Calling all React developers! Join us for an immersive 4-hour workshop diving deep into React Server Components and Server Actions. Discover how these game-changing technologies are revolutionizing web development and learn how to harness their full potential to build lightning-fast, efficient applications.
Explore the world of React Server Components, seamlessly blending server-side rendering with client-side interactivity for unmatched performance and user experience. Dive into React Server Actions to see how they combine client-side interactivity with server-side logic, making it easier to develop interactive applications without traditional API constraints.
Get hands-on experience with practical exercises, real-world examples, and expert guidance on implementing these technologies into your projects. Learn essential topics such as the differences between Server and Client Components, optimizing data fetching, passing data effectively, and maximizing performance with new React hooks like useActionState, useFormStatus and useOptimistic.
Whether you're new to React or a seasoned pro, this workshop will equip you with the knowledge and tools to elevate your web development skills. Stay ahead of the curve and master the cutting-edge technology of React 19. Don't miss out - sign up now and unleash the full power of React!

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

React Compiler - Understanding Idiomatic React (React Forget)
React Advanced 2023React Advanced 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
Watch video: React Compiler - Understanding Idiomatic React (React Forget)
Joe Savona
Mofei Zhang
2 authors
The Talk discusses React Forget, a compiler built at Meta that aims to optimize client-side React development. It explores the use of memoization to improve performance and the vision of Forget to automatically determine dependencies at build time. Forget is named with an F-word pun and has the potential to optimize server builds and enable dead code elimination. The team plans to make Forget open-source and is focused on ensuring its quality before release.
You Can’t Use Hooks Conditionally… or Can You?
React Summit 2023React Summit 2023
28 min
You Can’t Use Hooks Conditionally… or Can You?
Top Content
Watch video: You Can’t Use Hooks Conditionally… or Can You?
The Talk discusses the use of the Use hook in React and its ability to be used conditionally. It explains the concept of the fiber tree and how hooks values are stored in memory. The Talk also delves into the conditional use of useContext and how it differs from useState. It explores the process of updating context values and optimizing context rendering. The role of the provider in managing context values and rendering is emphasized.
Efficient State Management With Hookstate
React Advanced 2021React Advanced 2021
10 min
Efficient State Management With Hookstate
This Talk introduces hook state as a flexible and simple state management solution for React. It demonstrates how hook state can be used for global state management, as well as for managing state within individual components. The speaker highlights the ease of using hook state for tasks such as adding, updating, and removing tasks. The conclusion encourages further exploration of hook state for efficient state management in React applications.
Don't Forget React Memo
React Summit 2022React Summit 2022
7 min
Don't Forget React Memo
The Talk covers topics such as React memo compiler, use memo and use callback, building custom hooks, and the benefits of using use ref. It also explores the similarities between use memo and use ref, and the use of React Memo for preventing re-renders and optimizing expensive calculations. The speaker also shares personal information and contact details.
We Don’t Know How React State Hooks Work
React Summit Remote Edition 2021React Summit Remote Edition 2021
7 min
We Don’t Know How React State Hooks Work
This Talk provides an introduction to React Staytools, explaining how to use the state and setState function to update a counter. It also delves into the inner workings of React rendering, discussing the update queue and re-rendering conditions. The Talk concludes by mentioning the different modes of updating and triggering re-renders in React, and encourages further exploration of the source code and discussion in Discord.
We Don’t Know How React State Hooks Work
React Advanced 2021React Advanced 2021
28 min
We Don’t Know How React State Hooks Work
This talk explores how useState works under the hood and why it's important to understand. It addresses the common confusion around the callback to setState and provides insights gained from exploring React hooks source code. Knowing how useState works is important for learning patterns, debugging, and gaining confidence in our code. React manages the current value of hooks in a linked list and performs updates sequentially. React optimizes rendering by caching computations and performing shallow renders when the state doesn't change.