You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/docs/guides/does-this-replace-client-state.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ Well, let's start with a few important items:
8
8
- React Query is a **server-state** library, responsible for managing asynchronous operations between your server and client
9
9
- Redux, MobX, Zustand, etc. are **client-state** libraries that _can be used to store asynchronous data, albeit inefficiently when compared to a tool like React Query_
10
10
11
-
With those points in mind, the short answer is that React Query will likely replace _almost all of your **asynchronous** code that you currently pipe through your **client**state management library_.
11
+
With those points in mind, the short answer is that React Query **replaces the boilerplate code and related wiring used to manage cache data in your client-state and replaces it with just a few lines of code.**
12
12
13
-
For a vast majority of applications, the **client**state that is left over after migrating all of your async code to React Query is usually very miniscule. In rare cicurmstances, an application might indeed have a massive amount of synchronous client-only state (like a visual designer or music production application), in which case, you will probably still want a client state manager. And that's fine, you can use React Query along side client state managers without any issues!
13
+
For a vast majority of applications, the truly **globally accessible client state** that is left over after migrating all of your async code to React Query is usually very tiny.
14
14
15
-
So as _probable side-effect_, **yes**. React Query can replace Redux, MobX or any other global state manager, if you are primarily using it to cache your server-side data.
15
+
> There are still some cicurmstances where an application might indeed have a massive amount of synchronous client-only state (like a visual designer or music production application), in which case, you will probably still want a client state manager. In this situation it's important to note that **React Query is not a replacement for local/client state management**. However, you can use React Query along side most client state managers with zero issues.
16
16
17
-
## A more detailed example
17
+
## A Contrived Example
18
18
19
19
Here we have some "global" state being managed by a global state library:
20
20
@@ -25,7 +25,7 @@ const globalState = {
25
25
tasks,
26
26
users,
27
27
themeMode,
28
-
sidebarOpen,
28
+
sidebarStatus,
29
29
}
30
30
```
31
31
@@ -34,7 +34,7 @@ Currently, the global state manager is caching 4 types of server-state: `project
0 commit comments