Skip to content
Snippets Groups Projects
Commit 528c5eda authored by Hyun Woo Jeong's avatar Hyun Woo Jeong
Browse files

댓글 컴포넌트 생성, 작업 중

parent 566fe5db
No related branches found
No related tags found
No related merge requests found
import React, {useEffect, useState} from "react";
import "../css/Article.css"
import {Routes, Route, Link, useNavigate, Navigate } from 'react-router-dom';
import { useParams } from 'react-router-dom';
function Comments({data}) {
const [
_id, title, content, images, author,
keyword, latitude, longitude,
comments, likes, createdAt] = data;
const navigate = useNavigate();
function MoveTo(link){
navigate(link)
}
let listItem = []
listItem = comments.map((el)=>{
// http://localhost:8080/uploads/21701487062905.png
return(
<p>코맨트 테스트</p>
)});
return (
<div class="comment">
<p>{'코맨트 테스트{'}</p>
<p>{listItem}</p>
<p>{'}코맨트 테스트'}</p>
</div>
);
}
export default Comments;
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
} }
.article:hover { .article:hover {
background-color: #bbbbbb; background-color: #dddddd;
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ import React, { useEffect, useState, useContext} from 'react'; ...@@ -4,7 +4,7 @@ import React, { useEffect, useState, useContext} from 'react';
import Article from '../components/Article.js'; import Article from '../components/Article.js';
import { UserContext } from '../Context.js'; import { UserContext } from '../Context.js';
import MapLocator from '../components/MapForLoaction.js'; import MapLocator from '../components/MapForLoaction.js';
import Comments from '../components/Comments.js';
import axios from 'axios'; import axios from 'axios';
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
...@@ -39,33 +39,38 @@ function PostRead() { ...@@ -39,33 +39,38 @@ function PostRead() {
}, []); }, []);
console.log(article); console.log(article);
console.log(article?Object.values(article):"no"); console.log(article?Object.values(article):"no");
if (article) { if (article) {
return( return(
<div className="App" > <>
<div className="introduction" style={{display: 'flex'}}> <div className="introduction" style={{display: 'flex'}}>
<MapLocator loc={{lat: article.latitude, lng: article.longitude}} keyword={article.keyword}></MapLocator> <MapLocator loc={{lat: article.latitude, lng: article.longitude}} keyword={article.keyword}></MapLocator>
<div>
<Article data={Object.values(article)}></Article> <Article data={Object.values(article)}></Article>
<button>조와요</button>
</div> </div>
댓글창, 댓글쓰기, 조와요 누르기 </div>
포스트 내용 <form>
<p>현재 페이지의 파라미터는 { params.id } 입니다.</p> <div style={{display: 'flex'}}>
</div>) <button>댓글 작성</button>
<input type="text"></input>
</div>
</form>
<Comments data={Object.values(article)}></Comments>
</>
)
} }
else { else {
return( return(
<div className="App">
<h1>포스트 페이지</h1>
<div className="introduction" style={{display: 'flex'}}> <div className="introduction" style={{display: 'flex'}}>
<p>로딩준</p> <p>로딩준</p>
</div> </div>
</div>) )
} }
;
} }
async function requestLoadArticleById(id) { async function requestLoadArticleById(id) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment