console 창에서 아래의 문구와 같은 에러 내용이 나오는 경우 해결 방법입니다
"react-dom.development.js:86 Warning: ReactDOM.render is no longer supported in React 18.
Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.
Learn more: https://reactjs.org/link/switch-to-createroot"
수정 전 코드
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
수정 후 코드
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
수정 전 코드를 수정 후 코드와 같은 형태로 변경하면 console 더 이상 에러가 보이지 않습니다
참고
React js Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API
Recently i have been working in a React js project its show me an warning in my Browser Console which...
dev.to
'JavaScript > React(리액트)' 카테고리의 다른 글
[React] 이미 3000 포트를 사용 중 입니다 (0) | 2022.05.30 |
---|---|
[React] 구름IDE npx을 사용해서 리액트 앱 시작하기 (0) | 2022.04.25 |
리액트 보일러 프로젝트 - 5 개인 정보 숨기기, 설정 변경 (0) | 2020.11.30 |
리액트 보일러 프로젝트 - 4 nodemon 설치 (0) | 2020.11.20 |
[짧은 팁]npm 업데이트 방법 (0) | 2020.11.16 |