9 Remote data and reactive caching
This chapter covers
- Adding remote data to a React application
- Introducing the reactive cache
- Exploring remote data management libraries
All the applications we’ve built so far are local applications. By that, I mean applications that show data local to your computer. If you spin up one of the applications (such as the goal-tracking application from chapter 8), add some things to do, and then go to another computer, you cannot see the same data in any way. Even if you deploy the application to a website and go to the same website but on a different device (perhaps your phone), you will not be able to work on the same data that you do on your computer. You will also experience this situation if you use a different browser on the same computer.
The reason is that we store the data locally in the browser’s local storage. Local storage is like a cookie but allows for more data in a more complex structure, and it’s never sent to the server (as cookies can be).
That makes our applications far different from most applications you see out in the wild. On X (formerly Twitter), for example, we all see the same posts; you can interact with tweets by other people and they can interact with yours. This process requires sending the data to some remote server and receiving data from there.
Note The source code for the examples in this chapter is available at https://reactlikea.pro/ch09.