Fixing reactivity

This commit is contained in:
Imbus 2024-03-24 21:59:21 +01:00
parent 6be8925970
commit b324e0f16d

View file

@ -1,17 +1,22 @@
import { JSXElement, splitProps } from "solid-js";
import { JSXElement, createEffect, createSignal } from "solid-js";
import { PublicComment } from "../Util/api";
export function Comment(props: { comment: PublicComment }): JSXElement {
const [local] = splitProps(props, ["comment"]);
const dateOfCreation = new Date(local.comment.created_at).toDateString();
const [creationDate, setCreationDate] = createSignal<string>("");
const [content, setContent] = createSignal<string>("");
createEffect(() => {
setCreationDate(new Date(props.comment.created_at).toDateString());
setContent(props.comment.content);
});
return (
<>
<div class="py-5">
<time class="text-xs opacity-50">{dateOfCreation}</time>
<time class="text-xs opacity-50">{creationDate()}</time>
</div>
<div class="">{local.comment.content}</div>
<div class="">{content()}</div>
<div class="divider" />
</>
);