isDataEqual arguments are of type unknown
#1274
Replies: 7 comments 6 replies
-
I think you can narrow the type like this as well to avoid the cast: but yeah, it's effectively the same...
internally, I think @boschni what do you think? |
Beta Was this translation helpful? Give feedback.
-
|
The first time the data is fetched there is no reason to call |
Beta Was this translation helpful? Give feedback.
-
|
@dennismorello I think you could call
We could check if both prevData and data are undefined and then omit the call, but I think it’s also fine to handle that inside of |
Beta Was this translation helpful? Give feedback.
-
|
@TkDodo that is not the point of the issue 🤓 Don't get me wrong, but I expect That said, I would ask @tannerlinsley if
|
Beta Was this translation helpful? Give feedback.
-
|
For instance, SWR accepts a Moreover, I see from the react-query documentation that there is not a default compare function for |
Beta Was this translation helpful? Give feedback.
-
|
Seeing how this is not technically a bug, it's now a discussion. |
Beta Was this translation helpful? Give feedback.
-
|
Changed the type in V3 to But the structural sharing will already make sure a component is not re-rendered when the data did not change. The |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
The
isDataEqualfunction of theuseQueryconfiguration object is currently defined as follows:while I expected
oldDataandnewDatato be of typeTResult:Maybe there is a reason for those arguments to be of type
unknown, but ifisDataEqualis invoked only when the data has been correctly fetched, then they should be typed asTResult.To Reproduce
Steps to reproduce the behavior:
isDataEqualproperty of theuseQueryhookoldDataandnewDataarguments are of typeunknown, forcing the user to explicitly write type assertions:Expected behavior
isDataEqualarguments are of typeTResult.Desktop (please complete the following information):
Beta Was this translation helpful? Give feedback.
All reactions