-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.9.0-beta - forceRefetch doesn't trigger for queries with object as args #2816
Milestone
Comments
Interesting. Thanks for the repro! Will try to look at this in the next few days. |
This is causing us issues as well. |
Hmm. At first glance, it seems to be related to this check: export function useStableQueryArgs<T>(
queryArgs: T,
serialize: SerializeQueryArgs<any>,
endpointDefinition: EndpointDefinition<any, any, any, any>,
endpointName: string
) {
const incoming = useMemo(
() => ({
queryArgs,
serialized:
typeof queryArgs == 'object'
? serialize({ queryArgs, endpointDefinition, endpointName })
: queryArgs,
}),
[queryArgs, serialize, endpointDefinition, endpointName]
)
const cache = useRef(incoming)
useEffect(() => {
if (cache.current.serialized !== incoming.serialized) {
cache.current = incoming
}
}, [incoming])
return cache.current.serialized === incoming.serialized
? cache.current.queryArgs
: queryArgs
} Still digging into this. |
Should be fixed now. Will put out another beta later today. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New to rtkquery and was playing around with the merge & forceRefetch functionality for
1.9.0-beta.0
and it seems like forceRefetch doesn't work how Im expecting if a query has an object for the argument.Sandbox reproduction: https://codesandbox.io/s/merge-query-sandbox-forked-jjo0y7?file=/src/services/pokemon.ts
For example if I have a query that looks like:
Im expecting the query to re-fire whenever pageNumber changes - which doesn't seem to be the case. However, if I change the query to a number argument for example:
Then it seems to work as expected. The issue being if a query needs multiple arguments then I'm not sure how to trigger the forceRefetch. Not sure if I'm perhaps using forceRefetch incorrectly however.
The text was updated successfully, but these errors were encountered: