/*global kakao*/ import axios from 'axios'; import React, { useEffect, useState } from 'react'; import { Container, Row, Image } from 'react-bootstrap'; import queryString from 'query-string' import { Link } from 'react-router-dom'; import ohuh from '../ohuh-sm.PNG'; function Place(props) { console.log(props) const [db, setDb] = useState(false) const [index, setIndex] = useState(0) const [reviews, setReviews] = useState([]) const place = queryString.parse(props.location.search).place const getReview = (index) => { console.log(index, "dlseprtm") axios({ url: `/api/review?keyword=${place}&index=${index}`, method: 'post', data: { db: db } }) .then(res => { console.log("place res.data", res.data) setReviews([...reviews, ...res.data.review]) setDb(res.data.db) setIndex(res.data.index) }) .then(() => { console.log(index, "인텍스", db) }) .catch(err => { console.log(err) }) } useEffect(() => { // const script = document.createElement("script"); // script.async = true; // script.src = // "https://dapi.kakao.com/v2/maps/sdk.js?appkey=908d6cabedae3bbac126305e53137d0d&autoload=false"; // document.head.appendChild(script); // script.onload = () => { // kakao.maps.load(() => { // let container = document.getElementById("Mymap"); // let options = { // center: new kakao.maps.LatLng(37.506502, 127.053617), // level: 7 // }; // const map = new window.kakao.maps.Map(container, options); // }); // } getReview(); window.addEventListener("scroll", infiniteScroll); return () => { window.removeEventListener("scroll", infiniteScroll); } }, []); // useEffect(() => { // getReview(); // }, [index]) const infiniteScroll = () => { const { documentElement, body } = document; const scrollHeight = Math.max(documentElement.scrollHeight, body.scrollHeight); const scrollTop = Math.max(documentElement.scrollTop, body.scrollTop); const clientHeight = documentElement.clientHeight; if (scrollTop + clientHeight >= scrollHeight) { // setIndex(index + 1) getReview(index + 1); console.log("더불러", index + 1) } console.log(scrollHeight, scrollTop, clientHeight) } return (

{place}

관광지 정보
{/* */} {/*

@username Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.

Placeholder32x32

@username Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.

Placeholder32x32

@username Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.

*/} 사진 더보러가기
관광지 후기
{Array.isArray(reviews) ? reviews.map((review, index) => { return (
{review.title} 블로그로 이동
{review.summary}
) }) : "리뷰가 없습니다."} 리뷰 더보기
// // {place} // {Array.isArray(reviews) ? reviews.map((review, index) => { // return ( // // {review.title} //
{review.summary}
//
{review.content}
//
// ) // }) // : "리뷰가 없습니다."} //
); } export default Place;