FrostByte/client-solid/src/SinglePost.tsx

18 lines
510 B
TypeScript
Raw Normal View History

2023-10-27 16:04:58 +02:00
import { useParams } from "@solidjs/router";
2023-11-13 12:00:46 +01:00
import { JSXElement, Show, Suspense, createResource } from "solid-js";
2023-10-27 16:04:58 +02:00
import { getPost } from "./api";
import { PostSegment } from "./Posts";
2023-11-13 12:00:46 +01:00
export function SinglePost(): JSXElement {
2023-10-27 16:04:58 +02:00
const params = useParams();
const [post] = createResource(params.postid, getPost);
return (
<Suspense fallback={<div>Some loading message</div>}>
<Show when={post()}>
<PostSegment post={post()!}></PostSegment>
</Show>
</Suspense>
);
}