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"; | import { PublicComment } from "../Util/api"; | ||||||
| 
 | 
 | ||||||
| export function Comment(props: { comment: PublicComment }): JSXElement { | export function Comment(props: { comment: PublicComment }): JSXElement { | ||||||
|   const [local] = splitProps(props, ["comment"]); |   const [creationDate, setCreationDate] = createSignal<string>(""); | ||||||
|   const dateOfCreation = new Date(local.comment.created_at).toDateString(); |   const [content, setContent] = createSignal<string>(""); | ||||||
|  | 
 | ||||||
|  |   createEffect(() => { | ||||||
|  |     setCreationDate(new Date(props.comment.created_at).toDateString()); | ||||||
|  |     setContent(props.comment.content); | ||||||
|  |   }); | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|     <> |     <> | ||||||
|       <div class="py-5"> |       <div class="py-5"> | ||||||
|         <time class="text-xs opacity-50">{dateOfCreation}</time> |         <time class="text-xs opacity-50">{creationDate()}</time> | ||||||
|       </div> |       </div> | ||||||
|       <div class="">{local.comment.content}</div> |       <div class="">{content()}</div> | ||||||
|       <div class="divider" /> |       <div class="divider" /> | ||||||
|     </> |     </> | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus