TanStackT
TanStack3y ago
5 replies
wet-aqua

onSuccess migration: what to do for this use case?

Hey friends, I read TkDodos blog about killing the onSuccess APIs and that seems great, I'd love to hop on board. Everything he writes about makes a good amount of sense and I totally see the overarching reason -- onSuccess for useQuery creates a lot of anti-patterns.

There is one use case I still can't wrap my head around -- creating arbitrary values for client side rendering in server side data.

I have this state for ingredients, which, from the client, accepts a "selection". The database does not need to know, and should not know this information. The client messes with it and we do something with that client side state later.

I basically do this:
onSuccess: (data)=>{
...data,
selection: 2,
other_clientside_info: 'hi'
}

how can I give my server side data arbitrary values like this?

Thanks!
Was this page helpful?