Fixing reactivity
This commit is contained in:
		
							parent
							
								
									6be8925970
								
							
						
					
					
						commit
						b324e0f16d
					
				
					 1 changed files with 10 additions and 5 deletions
				
			
		|  | @ -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" /> | ||||
|     </> | ||||
|   ); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus