Replies: 1 comment
-
stackoverflow question has been answered. No, arguments do not need to be referentially stable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
DISCLAIMER: This was originally asked on StackOverflow (https://stackoverflow.com/questions/72723445/should-the-arguments-passed-to-react-querys-usequery-hook-be-referentially-stab) and as of the time of writing has yet to receive an answer.
I am going through an existing codebase, looking at some data fetching hooks that use
useQuery
I am noticing that, almost everywhere, care is taken so that the arguments passed in the
useQuery
hook (and other similarreact-query
hooks) are referentially the same between hook executions.For example
My question is this:
Is it necessary to ensure referential stability for the
useQuery
,useMutation
, etc, arguments? As far as I could tell the docs do not say you should do this.Would the
react-query
hooks redo calculations on every component re-render if their arguments are not referentially the same between renders?Would the
react-query
hooks return some referentially different items within their return object value if their arguments are not referentially the same between renders? (for example themutate
function inside the return object ofuseMutation
)Beta Was this translation helpful? Give feedback.
All reactions