Created
May 15, 2020 17:54
-
-
Save nsantos16/3ac5eac3d607b89f2b11a56821390462 to your computer and use it in GitHub Desktop.
React Query mutation demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [mutate, mutationState] = useMutation(patchMovies, { | |
onSuccess: newMovie => { | |
// Update `movies` while refetching all the list on background | |
queryCache.refetchQueries(movies"); | |
queryCache.setQueryData(["movies", { id: newMovie.id }], newMovie); | |
} | |
}); | |
const onSave = newMovie => mutate(newMovie); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment