1
00:00:00,000 --> 00:00:03,300
TanStack Query already has my products.

2
00:00:03,300 --> 00:00:06,300
Do I need to copy them into a global store?

3
00:00:06,300 --> 00:00:08,800
The database apparently needs a roommate.

4
00:00:08,980 --> 00:00:10,300
Usually, no.

5
00:00:10,300 --> 00:00:12,200
Components using the same query key

6
00:00:12,200 --> 00:00:14,500
and QueryClient share the cached result.

7
00:00:14,500 --> 00:00:16,170
A second copy creates another

8
00:00:16,170 --> 00:00:18,100
place you must keep synchronized.

9
00:00:18,280 --> 00:00:20,637
Two readers use this same key.

10
00:00:20,637 --> 00:00:23,500
Thirty thousand means thirty seconds of freshness.

11
00:00:23,500 --> 00:00:25,530
Filters that change the fetched data

12
00:00:25,530 --> 00:00:27,120
must also be part of the key.

13
00:00:27,300 --> 00:00:30,600
Your unfinished search text can stay in useState.

14
00:00:30,600 --> 00:00:32,590
It is user input, not a

15
00:00:32,590 --> 00:00:34,940
second copy of the server's products.

16
00:00:35,120 --> 00:00:37,620
Use a client store for genuinely shared

17
00:00:37,620 --> 00:00:40,300
client state, like an editor's tool selection.

18
00:00:40,300 --> 00:00:42,980
Query handles server synchronization; it does

19
00:00:42,980 --> 00:00:45,080
not replace every kind of state.

20
00:00:45,260 --> 00:00:48,400
I copied the cache for convenience.

21
00:00:48,400 --> 00:00:52,140
Now both copies disagree professionally.
