-
-
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
RTK-Query updateQueryData callback is not called #2247
Comments
|
Is there any other way to add new data to cache? |
Not exactly at the moment. There's an open PR to add something along those lines, but it needs more work: |
Hey guys sorry to bother you again, I am really trying to learn rtk-query, and I'm trying a little bit different usecase now, and that is to optimistically update existing query data, and again updateQueryData callback is not getting called..
Update is called after visiting (and fetching) getById route with same id that I am updating.
And this is my api config in case you need it..
I don't know if I should open different issue or it is okay to ask you here... |
It's hard to see what you're doing with those snippets. Can you post an entire example as either a CodeSandbox, a Github repo, or a Replay ( https://replay.io/record-bugs )? |
Hello I'm sending you Github repo here: https://github.com/WingsDevelopment/rtk-query-demo |
@WingsDevelopment you sohuld use the exact argument that you are putting into the If you call it |
I knew that already, but it seems there is something I don't understand because I thought that I am already doing that... I am passing everywhere: id I am not sure if you saw code for getAll and you are answering because of that?... But my qustion is about getById and updateFruit under the comment 'THIS DOESN'T WORK' that can be found here: https://github.com/WingsDevelopment/rtk-query-demo/blob/main/src/api/FetchDataApi.js |
Okay I got it, there was a problem with the type in this case after converting id to string in line before it started working.. I guess adding this at least to documentation (correct me if I am wrong but I haven't found anything about this), or loging some warning/error would be nice.. :D But I'm glad I got it to work.. Thanks for help! |
Thanks man, that was an issue on my side too... I spent a lot of time debugging this. 😕 |
Hi, guys. Sorry for hijacking the thread but it's kind of related. I was also not having the Now the problem is that the callback has as argument a |
@arquadrado : assuming you returned an array of data earlier from the response, yes, I would expect that you could do If you try |
@markerikson thank you for input. The problem was indeed that we were transforming the response of the |
I am trying to manually add query data cache for each item in list, after loading whole list.
It's simple table view, after which I would like to have instant load on each details view for any of the items in the list.. And I can't make it work, seems like updateQueryData callback is not called.
Keep in mind that at the moment when getAll function gets called, there isn't any getById queryes in cache! I am not sure if that's issue here..
This is my api code for getAll(list view):
And this is my getById(details view) api code:
The text was updated successfully, but these errors were encountered: