This file contains hidden or 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
// 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 |