8 Data management in React
This chapter covers
- Introducing the importance of data management
- Evaluating various data management libraries
- Building the data layer of an application in five ways
We’ve been using data in all the apps we’ve built, from the value of an input field to the list of items in a to-do application. I’ve introduced several ways to handle data as well. We’ve used useState
for single data values and useReducer
for more complex multivalue state. We’ve also discussed how React context can help you distribute and manipulate your data throughout your application in meaningful yet simple ways.
But there are many more ways to manage data in an application. Especially as applications grow large and complex, it can make sense to use a more structured approach to data management rather than sprinkle useState
hooks all over the codebase with no clear structure behind them.
By data management, I mean the process of storing, reading, and modifying data locally in the application as the user goes about their business in the application. Data in this context can be different things, including UI state (whether the menu is open or closed), form state (what is currently entered in each input), and application state (the movie object that you can edit). Data can also include read-only data, such as all the articles in the blog section of the application.