Skip to content

Commit

Permalink
Fix Deprecated code (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukapetro authored Dec 9, 2023
1 parent 40b300f commit 9f8a4fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions apps/expo/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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("");
Expand Down Expand Up @@ -97,7 +97,7 @@ function CreatePost() {
}

const Index = () => {
const utils = api.useContext();
const utils = api.useUtils();

const postQuery = api.post.all.useQuery();

Expand Down
12 changes: 6 additions & 6 deletions apps/nextjs/src/app/_components/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand All @@ -15,7 +15,7 @@ export function CreatePostForm() {
async onSuccess() {
setTitle("");
setContent("");
await context.post.all.invalidate();
await utils.post.all.invalidate();
},
});

Expand All @@ -31,7 +31,7 @@ export function CreatePostForm() {
});
setTitle("");
setContent("");
await context.post.all.invalidate();
await utils.post.all.invalidate();
} catch {
// noop
}
Expand Down Expand Up @@ -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 (
Expand All @@ -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
Expand Down

0 comments on commit 9f8a4fa

Please sign in to comment.