"use client"; import { useState } from "react"; import { api } from "@/trpc/react"; export function LatestPost() { // const { data: latestPost } = api.post.getLatest.useQuery(); const utils = api.useUtils(); const [name, setName] = useState(""); const createPost = api.post.create.useMutation({ onSuccess: async () => { await utils.post.invalidate(); setName(""); }, }); return (
{/* {latestPost ? (

Your most recent post: {latestPost.name}

) : (

You have no posts yet.

)} */}
{ e.preventDefault(); createPost.mutate({ name }); }} className="flex flex-col gap-2" > setName(e.target.value)} className="w-full rounded-full px-4 py-2 text-black" />
); }