-
-
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
skipToken passed to serializeQueryArgs #3151
Comments
Can you give an example of this happening? |
I am also affected by this. In my case this is triggered by just calling the auto-generated lazy query hook in a component. const MyComponent = () => {
useLazyGetQuery();
return null;
} |
I am also affected by this |
Hi there. I just upgraded @reduxjs-toolkit to 2.4.0 but am still seeing that Calling query in React component: import { skipToken } from '@reduxjs/toolkit/query/react';
// inside component
const [userId, setUserId] = useState('');
const { data, error, isFetching, isLoading } = useGetUserQuery(userId || skipToken ); API slice: const apiSlice = createApi({
...
endpoints: (build) => ({
getUser: build.query<...>({
queryFn: (userId) => { ... }
serializeQueryArgs: ({ queryArgs: userId }) => {
console.log({userId}); // this returns { userId: Symbol(RTKQ/skipToken) }
return userId;
};
}),
})
}); I realize that in this example, serializeQueryArgs is not necessary because it would be caching on userId by default anyway, but I just wanted to demonstrate that it's still getting called when I want to skip the query. |
@jshih7 hmm. out of curiosity, if you change that to a |
Sorry, I'm debugging this within an application for work so it'll be difficult for me to share exact details. However, the stack trace looks something like this:
In the ParentComponent, I'm calling a dispatch to the Redux store to modify state, which re-renders the ChildComponent and triggers the query fetch in the child, which then calls serializeQueryArgs. |
Ah. I bet it's because we also call it at the hook level, in a
that needs to be addressed as well. |
Thanks - if you're able to address and create a new build (could be a beta build), I can install and confirm that it's working on my end. |
I took a look at the code you sent, it looks like I went back to the Here is the more complete stack trace, with code snippets at the line number:
Based on this, I think the issue is that we shouldn't need to perform the |
Hey @markerikson , I created a code sandbox to reproduce this issue: https://codesandbox.io/p/sandbox/zen-brook-hhmw4c If you type in "charizard" in the input field, you'll see results from calling There is actually another unexpected behavior that I encountered during my testing (I can open a new issue for this as well). When clearing the field, I expect that the query would return In summary, here's the current behavior:
|
@jshih7 : fwiw off the top of my head I think that the |
@markerikson Thanks, I jumped the gun, haha. Shortly after I posted that, I found a couple discussions where you and others pointed out the difference between For my use case, |
It looks like when you specify and endpoint-specific
serializeQueryArgs
, it's possible forqueryArgs
to equalskipToken
This is unexpected since it's not reflected in the typescript type. Either the typescript type should be updated, or skipToken should be filtered out
The text was updated successfully, but these errors were encountered: