React 18에서 TS2339: Property 'createRoot' does not exist on type 'typeof import… 오류 해결법
React 18에서 TS2339: Property 'createRoot' does not exist on type 'typeof import… 오류 해결법에 대한 핵심 내용과 바로 적용할 포인트를 정리한 글입니다.
Author
Younggun Park
Frontend engineer and builder · Seoul, South Korea
I'm building Vision AI products at P2ACH AI, writing about frontend systems, AI tooling, and the quiet parts of shipping.
TL;DR
React 18에서 TS2339: Property 'createRoot' does not exist on type 'typeof import… 오류 해결법에 대한 핵심 내용과 바로 적용할 포인트를 정리한 글입니다.
https://velog.io/@seungmini/TypeScript에-React18-적용하기
글을 충분히 따라갔다면
index.tsx 파일의 코드는
TypeScript
import React from 'react';
import ReactDOM from "react-dom/client";
import App from './App';
const rootElement = document.getElementById('root');
if (!rootElement) throw new Error('Failed to find the root element');
const root = ReactDOM.createRoot(rootElement); // 요부분
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);이렇게 바뀐다. 여기서 내가 마주쳤던 오류는
React 18에서 index.tsx에 TS2339 오류가 발생하는데..
TypeScript
TS2339: Property 'createRoot' does not exist on type 'typeof import…여기서는 CreateDOM을 사용하여
TypeScript
import CreateDOM from 'react-dom/client';
...
const root = CreateDOM.createRoot(rootElement);이렇게 바꿔주면 더이상 오류는 발생하지 않는다.
해당 문제는 @types/react-dom@^18.0.0 이상 설치하여야 해결이 가능하다.
reference
FAQ
Common follow-up questions
- 이 글의 핵심은 무엇인가요?
- React 18에서 TS2339: Property 'createRoot' does not exist on type 'typeof import… 오류 해결법에 대한 핵심 내용과 바로 적용할 포인트를 정리한 글입니다.
- 실무적으로 먼저 볼 포인트는 무엇인가요?
- React 18에서 TS2339: Property 'createRoot' does not exist on type 'typeof import… 오류 해결법에 대한 핵심 내용과 바로 적용할 포인트를 정리한 글입니다.
Tags
Related posts
View all writingNext.js 마이그레이션으로 고생했는데, 새로운 기술은 시간과 노력을 충분히 들일 수 있을 때 시작. 급하면 익숙한것 먼저 사용한 후 다음에 바꾸는 것을 추천. 기술을 공부하고 싶으면 사용하는 것도 좋을듯.
Dec 7, 2023하루종일 Webstorm을 잡고 Next.js 버전 문제, 쿠키 모듈 수정 등 여러가지 시도를 해봤으나 답을 알 수 없는 상황에서 오늘 올라온 스택 오버플로우의 질문과 답변으로 해결됐다.
Oct 17, 2023