What Is State and How Do We Manage It?
State is a mutable data source that can be used to store data in a React application and can change over time and be used to determine how your component renders.
This chapter will refresh your existing knowledge about state in the React ecosystem. We will review what it is and why it is needed, and understand how it helps you build React applications.
We’ll also review how you can manage state natively in React by using the useState hook, the useReducer hook, and React Context.
Finally, we’ll offer brief descriptions of the common state management solutions such as Redux, Zustand, and MobX and understand why they have been created and the main common concept they all share.
By the end of this chapter, you will have either learned or remembered everything about state necessary to proceed in this book. You will also notice a pattern in how state is managed between different state management solutions and meet or get reacquainted with a familiar term. Spoiler alert: it is global state.
In this chapter, we’ll be covering the following topics:
- What is state in React?
- Managing state in React
- What do different state management libraries have in common?