Skip to content

Instantly share code, notes, and snippets.

View aaronmasm's full-sized avatar
🏠
Working from home

Aarón Más Murro aaronmasm

🏠
Working from home
View GitHub Profile
@aaronmasm
aaronmasm / react-query-mutation-pattern.ts
Last active May 9, 2025 01:11
React Query Mutation Pattern
// Reusable mutation pattern using React Query + TypeScript
// Applies to typical POST, PUT, PATCH, or DELETE operations
// Handles success notifications, redirection, and error handling
import { useMutation } from "@tanstack/react-query";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
// You should define this function in your API service layer
// Example: POST /projects