How to properly redirect to different page using trpc?
export default function Post() {
const { id } = useRouter().query;
const postByIdQuery = trpc.post?.byId.useQuery({
userId: session?.user?.id,
id: String(id),
});
const { data: post } = postByIdQuery
if (!post) {
return <Error statusCode=404>
}
return (
<h1>{post.title}</h1>
<p>{post.desc}</p>
)
}Previously i use the getServersideProps and if the api returns nothing then simply redirect
the above method does not render the 404 page for some reason
