Why We Switched to React Query for Managing Server State
Long guide into how React Query works for managing state in your FE applications
Redux is great for managing client state: it allows data to be synchronized across the whole app, reduces prop drilling, and makes it easier to understand when state changes occur.
Server state is a different story. Sure, it’s nice to have data available everywhere in our app, which is why we tend to fetch data from the server and dump it into our Redux store. But because our client application doesn’t own that server data, it’s hard to know when it has become stale. And what if multiple components trigger calls to fetch the same data? How do you dedupe requests? How do you decide when to refetch?
Below, we’ll dive into how we’re using React Query at Alto to solve these problems and achieve separation of client and server state.