-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
The data object returned by useQuery is always different after a server request is executed, even when the server response is exactly the same.
This can be problematic in some cases, for example using data on a useEffect hook will cause the hook to be executed every time a request is sent, when what I would expect is for it to be triggered only when the actual data changes.
It's also worth noting this is not the case with swr, it will only trigger other hooks when the actual data has changed.
If this is a conscious design decision, it would be great to have it documented. For my current project this is a deal breaker, and it would have saved me some time to know this before hand.
I've created a simple example here https://codesandbox.io/s/react-query-memo-wlw2v?file=/src/App.tsx. You can switch between swr and react-query on line 18 and check in the console to see how memo is triggered every time a request is done.