From b324e0f16df0dda787b84ecc5bb440b46ce88cf5 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 24 Mar 2024 21:59:21 +0100 Subject: [PATCH] Fixing reactivity --- client-solid/src/Components/Comment.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client-solid/src/Components/Comment.tsx b/client-solid/src/Components/Comment.tsx index 4e64063..d78fa0a 100644 --- a/client-solid/src/Components/Comment.tsx +++ b/client-solid/src/Components/Comment.tsx @@ -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(""); + const [content, setContent] = createSignal(""); + + createEffect(() => { + setCreationDate(new Date(props.comment.created_at).toDateString()); + setContent(props.comment.content); + }); return ( <>
- +
-
{local.comment.content}
+
{content()}
);