Purpose of mutationKey in useMutation
Hi, can anyone explain to me what is the purpose of
mutationKey - there is very little information in the docs - it mentioned that this can be used to identify mutations in the dev tools but so far I am not able to inspect any mutation in the dev tools - I only see queries. What is the purpose of mutationKey and is it best practice to always put it in useMutation? Thank you! 🙂3 Replies
fair-rose•4y ago
mutations can't be seen in the devtools. if that is mentioned in the docs, a PR to change it would be nice
mutationKeys can be used to set mutation defaults for multiple mutations, or to be able to find them via
useIsMutatingadverse-sapphire•3y ago
Hi @TkDodo 🔮 , mutationKey doesn't invalidateQuery those useQuery that have the same mutationKey after successful mutation?
fair-rose•3y ago
no, it does not
but if you want that, you're a few lines of code away
https://x.com/TkDodo/status/1630321212013387776
(you can also use the mutationKey for that instead of meta)