해결된 질문
24.08.20 20:21 작성
·
67
0
import { useEffect } from "react";
declare const window: typeof globalThis & {
kakao: any;
};
export default function KakaoMapPage(): JSX.Element {
useEffect(() => {
const container = document.getElementById("map");
const options = {
center: new window.kakao.maps.LatLng(33.450701, 126.570667),
level: 3,
};
const map = new window.kakao.maps.Map(container, options);
console.log(map);
}, []);
return (
<>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=키"
></script>
<div id="map" style={{ width: 500, height: 400 }}></div>
</>
);
}
Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <div> in <div>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
카카오 맵 하는데 오류 왜 뜨는건가요??
답변 1
0
2024. 08. 21. 21:08
안녕하세요! br님!
해당 에러는 react 최신 버전을 사용하는 경우에 발생하고 있어요!
수업에서 사용하는 버전으로 다시 한 번 시도해 보세요!^^