diff --git a/apps/expo/src/app/index.tsx b/apps/expo/src/app/index.tsx index 3945068b5..c60fd0f0c 100644 --- a/apps/expo/src/app/index.tsx +++ b/apps/expo/src/app/index.tsx @@ -4,8 +4,8 @@ import { SafeAreaView } from "react-native-safe-area-context"; import { Link, Stack } from "expo-router"; import { FlashList } from "@shopify/flash-list"; -import { api } from "~/utils/api"; import type { RouterOutputs } from "~/utils/api"; +import { api } from "~/utils/api"; function PostCard(props: { post: RouterOutputs["post"]["all"][number]; @@ -37,7 +37,7 @@ function PostCard(props: { } function CreatePost() { - const utils = api.useContext(); + const utils = api.useUtils(); const [title, setTitle] = React.useState(""); const [content, setContent] = React.useState(""); @@ -97,7 +97,7 @@ function CreatePost() { } const Index = () => { - const utils = api.useContext(); + const utils = api.useUtils(); const postQuery = api.post.all.useQuery(); diff --git a/apps/nextjs/src/app/_components/posts.tsx b/apps/nextjs/src/app/_components/posts.tsx index f03108997..287609eab 100644 --- a/apps/nextjs/src/app/_components/posts.tsx +++ b/apps/nextjs/src/app/_components/posts.tsx @@ -2,11 +2,11 @@ import { useState } from "react"; -import { api } from "~/utils/api"; import type { RouterOutputs } from "~/utils/api"; +import { api } from "~/utils/api"; export function CreatePostForm() { - const context = api.useContext(); + const utils = api.useUtils(); const [title, setTitle] = useState(""); const [content, setContent] = useState(""); @@ -15,7 +15,7 @@ export function CreatePostForm() { async onSuccess() { setTitle(""); setContent(""); - await context.post.all.invalidate(); + await utils.post.all.invalidate(); }, }); @@ -31,7 +31,7 @@ export function CreatePostForm() { }); setTitle(""); setContent(""); - await context.post.all.invalidate(); + await utils.post.all.invalidate(); } catch { // noop } @@ -99,7 +99,7 @@ export function PostList() { export function PostCard(props: { post: RouterOutputs["post"]["all"][number]; }) { - const context = api.useContext(); + const utils = api.useUtils(); const deletePost = api.post.delete.useMutation(); return ( @@ -113,7 +113,7 @@ export function PostCard(props: { className="cursor-pointer text-sm font-bold uppercase text-pink-400" onClick={async () => { await deletePost.mutateAsync(props.post.id); - await context.post.all.invalidate(); + await utils.post.all.invalidate(); }} > Delete