Skip to content

Instantly share code, notes, and snippets.

@nsantos16
Created May 15, 2020 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsantos16/3ac5eac3d607b89f2b11a56821390462 to your computer and use it in GitHub Desktop.
Save nsantos16/3ac5eac3d607b89f2b11a56821390462 to your computer and use it in GitHub Desktop.
React Query mutation demo
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