I used the onSuccess callback, but it is called every time the data is successfully retrieved.
I expect to be called only when the data changed(deep equal). Is there any good way to do this?
useQuery(..., {
onSuccess(data) {
console.log(data)
}
})
// first: [1], second: [2], // => call
// first: [1], second: [1], // => not call
How to do this, thanks a lot!
onSuccess is tied to successful data fetching. If you want to spawn a side-effect whenever data changes, use a useEffect:
const { data } = useQuery(...)
useEffect(() => ..., [data])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With