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

leeso4567님의 프로필 이미지

작성한 질문수

처음 만난 리액트(React)

(실습) 시계 만들기

createRoot도 잘 했는데 에러가 나네요

해결된 질문

24.07.26 10:58 작성

·

158

·

수정됨

1

createRoot도 잘 되어있고 하는데도 이 에러가 뜹니다..

import Clock from "./chapter_04/Clock";

const root = ReactDOM.createRoot(document.getElementById("root"));
setInterval(() => {
  root.render(
    <React.StrictMode>
      <Clock />
    </React.StrictMode>
  );
}, 1000);

reportWebVitals();

ERROR

react_dom_client__WEBPACK_IMPORTED_MODULE_1__.render is not a function TypeError: react_dom_client__WEBPACK_IMPORTED_MODULE_1__.render is not a function at http://localhost:3000/static/js/bundle.js:114:49

답변 2

0

leeso4567님의 프로필 이미지
leeso4567
질문자

2024. 07. 26. 11:56

import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";

import Library from "./chapter_03/Library";
import Clock from "./chapter_04/Clock";

const root = ReactDOM.createRoot(document.getElementById("root"));
setInterval(() => {
  root.render(
    <React.StrictMode>
      <Clock />
    </React.StrictMode>
  );
}, 1000);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
index.js 파일입니다
Inje Lee (소플)님의 프로필 이미지
Inje Lee (소플)
지식공유자

2024. 07. 26. 12:03

일단 코드 상으로는 문제가 없어 보입니다.혹시 애플리케이션을 종료했다가 다시 실행해보시겠어요?
leeso4567님의 프로필 이미지
leeso4567
질문자

2024. 07. 26. 12:14

재실행 했더니 동작하네요! 감사합니다

0

Inje Lee (소플)님의 프로필 이미지
Inje Lee (소플)
지식공유자

2024. 07. 26. 11:07

안녕하세요, 소플입니다.혹시 index.js 파일의 전체 코드를 보여주시거나,GitHub에 공개된 저장소에 코드를 올리시고 링크를 알려주실 수 있을까요?전체 코드를 봐야 정확한 원인을 파악할 수 있을 것 같습니다~감사합니다.