TanstackQuery useMutation example
Hey folks, would like your takes/assistance on a silly one. I'm using TSQ for a small SolidJS project and I'm trying to create a mutation but it seems like the newer version does not support the previous version in which we passed a
mutationFn and a mutationKey . This is the way I usually go about it. I've got the follow function to create a thing:
And I'm trying to create a new mutation using the following:
But what i'm getting is an error stating that both mutationKey and mutationFn does not exist in our types anymore....Also the examples in the docs do not cover mutation creation anymore. How did ya'll work your way around this change?
P.S. Using "@tanstack/solid-query": "^5.59.17",
Edit: I know I can just use createQuery and achieve the same?? result but I really liked how we had separate actions to handle data fetching and data manipulation.2 Replies
like-goldOP•13mo ago
Found a solution, it was a silly one. We now create the mutation in the following way:
Had to dig in a bit into the src. Keeping the post up just in case there are other folks like me in the future.
conscious-sapphire•11mo ago
Does this support optimistic updates? The say this is supported but don't provide any examples https://tanstack.com/query/latest/docs/framework/solid/overview#well-that-seems-like-more-lines-of-code-to-do-the-same-thing