Remove redundant useCallbacks

This commit is contained in:
Justin Spahr-Summers
2024-11-08 12:00:46 +00:00
parent 5337baa116
commit 57f0c49154

View File

@@ -4,7 +4,6 @@ import { Input } from "@/components/ui/input";
import { TabsContent } from "@/components/ui/tabs";
import { Root } from "@modelcontextprotocol/sdk/types.js";
import { Plus, Minus, Save } from "lucide-react";
import { useCallback } from "react";
const RootsTab = ({
roots,
@@ -15,31 +14,25 @@ const RootsTab = ({
setRoots: React.Dispatch<React.SetStateAction<Root[]>>;
onRootsChange: () => void;
}) => {
const addRoot = useCallback(() => {
const addRoot = () => {
setRoots((currentRoots) => [...currentRoots, { uri: "file://", name: "" }]);
}, [setRoots]);
};
const removeRoot = useCallback(
(index: number) => {
const removeRoot = (index: number) => {
setRoots((currentRoots) => currentRoots.filter((_, i) => i !== index));
},
[setRoots],
);
};
const updateRoot = useCallback(
(index: number, field: keyof Root, value: string) => {
const updateRoot = (index: number, field: keyof Root, value: string) => {
setRoots((currentRoots) =>
currentRoots.map((root, i) =>
i === index ? { ...root, [field]: value } : root,
),
);
},
[setRoots],
);
};
const handleSave = useCallback(() => {
const handleSave = () => {
onRootsChange();
}, [onRootsChange]);
};
return (
<TabsContent value="roots" className="space-y-4">