인프런 커뮤니티 질문&답변

br님의 프로필 이미지

작성한 질문수

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

25-01-kakao-routing / kakao-routing-moved

카카오 맵 오류

해결된 질문

24.08.20 20:21 작성

·

67

0

image.png

 

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 최신 버전을 사용하는 경우에 발생하고 있어요!
수업에서 사용하는 버전으로 다시 한 번 시도해 보세요!^^

br님의 프로필 이미지

작성한 질문수

질문하기