Property 'useMutation' does not exist

Hello, I'm very new to T3 and pretty new to coding in general. Going through my first tutorial on youtube to build a simple application and it seems like there has been some small changes made recently in how you set up simple CRUD and I can't seem to figure it . Problem is simply that whenever I try to use tRPC's useMutation method here, it simply gives me an error saying that it "does not exist on type '{ useContext():..." despite following the tutorial.
const Home: NextPage = () => {
const [snippetText, setSnippetText] = useState("");
const snippet = trpc.useMutation("snippet.saveSnippet");

const handleSaveSnippet = async () => {
const newSnippet = await snippet.mutateAsync({
text: snippetText,
})
console.table(newSnippet);
}
const Home: NextPage = () => {
const [snippetText, setSnippetText] = useState("");
const snippet = trpc.useMutation("snippet.saveSnippet");

const handleSaveSnippet = async () => {
const newSnippet = await snippet.mutateAsync({
text: snippetText,
})
console.table(newSnippet);
}
4 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ruhroh
ruhrohOP3y ago
wow it worked perfectly. thank you very much! is this just a recent change in syntax recently that I wasn't able to find in the documentation? Only ask because Ive found several other ways to write it out (i.e trpc.snippet.useMutation("snippet.saveSnippet")), but none of them worked
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ruhroh
ruhrohOP3y ago
wow thank you very much!
Want results from more Discord servers?
Add your server