Goodbye, useState

Bookmark
Rate this content

State management is easy, until it's not. Sure, useState() is fine for simple component state management – that's literally what it's for. But as our React apps grow in complexity, the inevitable long chain of useStates make it more difficult to understand and maintain app logic, turning our components into Rube Goldberg machines.

React 19 opens up a whole new world of state management patterns that actually make sense for local, shared, and global state. In this talk, we'll transition from using useState() everywhere to discovering how server components, URL parameters, and more can make state management much simpler. We'll also revisit classic hooks, learn about new hooks, and see how 3rd-party state management libraries and local-first apps can be useful.

Let's say goodbye (mostly) to useState(), and hello to a future where state management isn't just a stack of setStates.

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

FAQ

The speaker is David K. P., the creator of the Xstate library.

David K. P.'s talk focuses on the pitfalls of using useState and useEffect in React and explores better state management patterns.

Overusing useState can lead to complex and hard-to-maintain code due to interactions between multiple states, which can cause performance issues and make the codebase difficult to understand.

Xstate is a state machine library for managing complex state logic in applications, and it was created by David K. P.

Alternatives to useState include useReducer for centralizing logic, useRef for non-rendering state, and third-party libraries like Xstate Store and Zustand for more advanced state management.

Developers can localize state to specific components, use context for shared state, and consider using libraries like Zustand to manage state more efficiently.

useReducer centralizes state logic, making it easier to test and maintain, and helps avoid scattered state updates across multiple components.

Third-party libraries like Xstate Store and Zustand offer more structured and efficient ways to manage state, especially in complex applications, reducing the need for reinventing state management solutions.

The future trend in state management involves local-first state or sync engines, which automatically synchronize local and database states for seamless data management.

David K. P. recommends using form management libraries like Final Form, TanStack Form, or React Hook Form for complex form validation instead of relying heavily on useState.

David Khourshid
David Khourshid
29 min
18 Nov, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Hello, React Summit and goodbye, you states. Introduction of the speaker, David K. P., creator of Xstate library. Discussion on challenges with useEffect, managing multiple useEffects, implications of state overuse, optimizing state management in React, enhancing form data handling, effective state management strategies, innovative state management approaches, state management best practices, exploring state management options, promoting best practices, and exploring state management tools.
Available in Español: Adiós, useState

1. Introduction to React Summit

Short description:

Hello, React Summit and goodbye, you states. Introduction of the speaker, David K. P., creator of Xstate library. Discussion on the theme of the talk related to states and React pitfalls.

Hello, React Summit and goodbye, you states. What do I mean by that? Let's get right into it. So first of all, who am I? Doesn't matter. You just heard, we have way too much to talk about.

But if you really need to know or stalk me on the socials, I'm David K. P. and I'm pretty much everywhere online. I created the library Xstate, which is a state machine library that if you saw the first talk, then you saw it demonstrated there. And speaking of states, I live in Florida, which is a very common migration path from New York.

I know we're not in New York, we're sort of in the wrong state, which is also the theme of my talk. But anyway, also I gave a talk a few years ago called Goodbye Use Effects, a very similar to this one. And in that talk, I explained a lot of the pitfalls of using use effect, why it's sort of a defective hook that is just sort of a really convenient foot gun. And of course, as expected, a lot of people were pretty angry about that talk saying this guy knows nothing about React.

2. Challenges with Use Effect

Short description:

Use effect challenges and the need for reevaluation. Exploring issues with adding multiple use dates and the resulting complexity in managing state. The interplay of use date with app logic causing extensive entanglement and challenges in code maintenance.

Use effect is super useful. But then, you know, stuff like this happens. And it happened again today, OK? I didn't plan it. I didn't cause it. But yeah, Foul Player is down again. I think they're still down. I'm not sure. It's because of use effect. But the React team actually came out with docs saying you might not need an effect. And these docs were pretty much my Goodbye Use Effect talk. So I might do the same thing for use effect that I did for use date because, honestly, we need to talk about it.

You know, this is not really OK. You know, we do have people online going like, hey, yeah, all we have to do is add another use date because what's the big problem with this? But I'm going to try to argue that you shouldn't do this, and we're going to explore some better patterns. Because you might be thinking, like, hey, use date is fine. I add one to my app. It's one of the simplest hooks. There's nothing really wrong with that. But then, you know, you add more, and it turns to use 8, and then things just sort of spiral out of control. And at that point, you're not vibe coding anymore. You're doing vibe state management. So it becomes a huge problem.

But, you know, what exactly is the problem with use date? It's not just use date in isolation. It's how use date interacts with everything else in your app logic, where you might have a use date being used in a use effect that needs to also update another use date. And then that might affect props in another component, which might trigger a use effect there, which calls use date internally in that component, which updates a prop, which calls use effects somewhere else. So it just becomes this huge, huge mess. This is actually an example of some real public code I've seen. And I mean, just look at this handler. I'm not saying this is bad. I'm not trying to shame them. This is actually a small startup.

QnA

Available in other languages:

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.
If You Were a React Compiler
React Summit US 2024React Summit US 2024
26 min
If You Were a React Compiler
Top Content
In this talk, the speaker aims to build an accurate understanding of how the new React compiler works, focusing on minimizing re-renders and improving performance. They discuss the concept of memoization and how it can be used to optimize React applications by storing the results of function calls. The React compiler automates this process by analyzing code, checking dependencies, and transpiling JSX. The speaker emphasizes the importance of being aware of memory concerns when using memoization and explains how the React compiler detects changes in function closure values. They also mention the Fibre Tree, which drives the reconciliation process and helps optimize performance in React. Additionally, the speaker touches on JSX transpilation, compiler caching, and the generation of code. They encourage developers to understand the code generated by the compiler to optimize specific sections as needed.
React Compiler Internals
React Summit 2025React Summit 2025
23 min
React Compiler Internals
Top Content
Introduction to React Compiler, its benefits, and the problem of memoization in React. Performance issues due to stateful components in React, solution with React.memo and use memo, and the benefits of React compiler in automating memoization. Compiler's transformation into high-level intermediate representation provides a clearer understanding of code operations and data flow, addressing the issues with unique identifiers for variables in complex scenarios. Compiler ensures each variable is assigned exactly once through single static assignment, resolving issues with variable values based on code paths and introducing unique names for assignments. Effects describe how operations interact with data, ensuring safe caching with types like read, store, capture, mutate, and freeze effects. The compiler understands operations but needs to identify values that change between renders for React, leading to the reactive analysis phase to determine reactive values in the component. Variables marked as reactive for potential changes between renders are optimized for caching. Compiler identifies dependencies to group operations for efficient caching. Scopes are established to cache related variables together and ensure efficient rendering and performance improvement in the final JavaScript code. Compiler sets up cache slots for dependencies and outputs to optimize performance. Scopes work independently to recalculate based on changes, ensuring efficient memoization. React Compiler streamlines memoization, providing automatic correct optimizations without manual burden, paving the way for performance-focused code.
Everything You Need to Know About React 19
React Summit US 2024React Summit US 2024
29 min
Everything You Need to Know About React 19
Watch video: Everything You Need to Know About React 19
React 19 introduces new features such as React Compiler and React Actions, which optimize code and provide better performance. The useOptimistic hook allows for optimistically updating UI, while the UseFormStatus hook tracks loading states and enables button disabling. The introduction of the 'action' attribute simplifies form handling and data retrieval. React 19 eliminates the need for useMemo and useCallback thanks to the React Compiler. The stability of React 19 has been observed in side projects without major issues.
What Refs Can Do for You
React Summit US 2024React Summit US 2024
27 min
What Refs Can Do for You
Today's Talk focused on using refs and profiling Agigrid in React. The speaker shared their experience with optimizing custom cell components and performance, including using memo and leveraging the React compiler. They also discussed improving performance with manual style updates and refactoring the use of useEffect. The speaker highlighted the use of ref callbacks, which can be implemented with useLayoutEffect. React 19 introduces changes to the ref callback approach. The Talk touched on using React DevTools and CSS variables for monitoring renders. It also discussed the compatibility of Azure Grid with React and the trade-offs between using React components and vanilla JavaScript. The speaker emphasized the importance of considering the DX improvements and the complexity of not seeing a React component tree in the dev tools. The Talk concluded with a mention of AG Grid features, handling refs at various levels, and the recommendation to consult with Stephen for technical questions and application architecture.
React 19 and the Compiler for the Rest of Us
React Day Berlin 2024React Day Berlin 2024
30 min
React 19 and the Compiler for the Rest of Us
Hi everyone. I'm Johnny, an application engineer who builds user-centric React 19 applications. Today, our goal is to help you reach production mountain with React 19. Let's start by gathering a crew and discussing the motives for installing the compiler. We'll revisit React rules and explore the compiler's impact on code. The React compiler translates from JavaScript to JavaScript and provides error reporting. It enables deeper levels of optimization and focuses on user experience. To upgrade to React 19, install the latest version and be aware of any compatibility issues. Check if any custom runtime code needs to be disabled. The React compiler can be used with versions 17 or 18 if you have runtime support. The compiler removes use memos and optimizes the initialization process based on static components. It provides granular reactivity and reduces rendering, making the application feel quicker. Follow React rules and conventions to ensure compatibility. Test custom hooks, be aware of the impact on build time, and address any unexpected issues like the removal of the global JSX namespace. Debugging tools and source mapping in Chrome are useful for understanding compiler output. Enjoy translating chants and exploring the possibilities of React 19!

Workshops on related topic

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!
Evolution of Form Management in React
React Summit US 2024React Summit US 2024
72 min
Evolution of Form Management in React
Workshop
Adrian Hajdin
Adrian Hajdin
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 GoalsLatest React 19 Hooks — useTransition, useFormStatus, useOptimistic, useActionState, useDeferredValueServer ActionsRevalidationsServer-side ValidationError handlingSecurity practices