# queryClient.setQueryData

**URL:** <https://forum.codewithmosh.com/t/queryclient-setquerydata/21541>\
**Category:** React\
**Created:** [July 16, 2023, 8:41pm UTC](https://forum.codewithmosh.com/t/queryclient-setquerydata/21541 "2023-07-16T20:41:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alfonsotis](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@alfonsotis](https://forum.codewithmosh.com/u/alfonsotis)\
**Post date:** [July 16, 2023, 8:41pm UTC](https://forum.codewithmosh.com/t/queryclient-setquerydata/21541/1 "2023-07-16T20:41:26Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/f/f0faaaac11f2cf9e6ed63fdc3eefa3c8b7f57da7.png)

"Hi!

I’m wondering if `queryClient.setQueryData` is still used the same way as shown in the “Mutating Data” video of the intermediate React course.

I have tried using `queryClient.setQueryData`, but it doesn’t seem to work for me, neither in the `onMutate` nor `onSuccess` callbacks, even though I’m receiving the object correctly from jsonplaceholder. Is there an issue with the library versions?"

---

<div class="post-metadata">

**Author:** ![alfonsotis](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@alfonsotis](https://forum.codewithmosh.com/u/alfonsotis)\
**Post date:** [July 16, 2023, 8:46pm UTC](https://forum.codewithmosh.com/t/queryclient-setquerydata/21541/2 "2023-07-16T20:46:09Z")

</div>

this is the good picture,

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/d/d38a0bb7b1227bea6b10bb433349f1c8e94b852c.png)

---

<div class="post-metadata">

**Author:** ![alfonsotis](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@alfonsotis](https://forum.codewithmosh.com/u/alfonsotis)\
**Post date:** [July 17, 2023, 5:31pm UTC](https://forum.codewithmosh.com/t/queryclient-setquerydata/21541/3 "2023-07-17T17:31:02Z")

</div>

I have already solved it, it came from App.tsx where I was using PostList instead of Todolist

---

<div class="post-metadata">

**Author:** ![gengsu07](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gengsu07](https://forum.codewithmosh.com/u/gengsu07)\
**Post date:** [August 14, 2023, 3:54am UTC](https://forum.codewithmosh.com/t/queryclient-setquerydata/21541/4 "2023-08-14T03:54:57Z")

</div>

i’m facing same problem but i’ve used Todolist in App.tsx  
is there anything wrong?

 ![setquerydata](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/7/77d9d9c9eb9d076103aa53f3965147df3b385c0d.png)

---

<div class="post-metadata">

**Author:** ![gengsu07](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gengsu07](https://forum.codewithmosh.com/u/gengsu07)\
**Post date:** [August 14, 2023, 4:05am UTC](https://forum.codewithmosh.com/t/queryclient-setquerydata/21541/5 "2023-08-14T04:05:09Z")

</div>

sorry i just solved the problem after ask chatgpt wkwk…

The problem is the queryclient  
**Using a New Query Client Instance:** In your `TodoForm` component, you’re creating a new instance of `QueryClient` each time the component is rendered. This is not the correct approach. You should use the same `QueryClient` instance that you’ve set up in your application. You can do this by importing the query client from the file where you’ve initialized it and then use it in your component.
