โพ ์๋ก์ด ๋ฆฌ์กํธ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๊ณ run์ ํ๋๋ ์ด๋ฐ ์ฝ์์ฐฝ์ด ๋ด๋ค.
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
โพ ๋ฆฌ์กํธ 18์์๋ ReactDOM.render๊ฐ ์๋๋ผ, createRoot๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค๊ณ ํ๋ค.
๊ทธ๊ฒ ๋ญ์ง? ๋ผ๋ฉฐ... ๊ณต์๋ฌธ์ ๋ณด๋ฌ ๊ณ ๊ณ - https://ko.reactjs.org/docs/concurrent-mode-reference.html#createroot
Concurrent ๋ชจ๋ API ์ฐธ๊ณ ์ (์คํ ๋จ๊ณ) – React
A JavaScript library for building user interfaces
ko.reactjs.org
โพ ๋ด์ผํ ๋ฌธ์๋ถ๋ถ ์บก์ณ
โพ ์์ ํ ์ฝ๋
index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter } from "react-router-dom";
import { Provider } from 'react-redux';
import store from './redux/config';
const rootNode = document.getElementById('root');
ReactDOM.createRoot(rootNode).render(
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>,
</Provider>,
);
// 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();
ํ์ฌ ์ฐ๊ณ ์๋ ์ฝ๋๋ฅผ ๊ฐ์ ธ์์ ์ก๋คํ ๊ฒ๋ค๋ ํจ๊ป ํฌํจ๋์ด์๋๋ฐ.. rootNode ๋ถ๋ถ์ ๋ณ๊ฒฝํด์ฃผ๋ฉด ๋๋ค.
๋ ๋ค๋ฅธ ๋ฐฉ์์ด ์์๊น ๊ตฌ๊ธ๋ง์ ๋ ํด๋ณด์๋ค!
createRoot๋ฅผ import ํ๋ ๋ฐฉ๋ฒ๋ ์๋ค~
import React from 'react';
import {createRoot} from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter } from "react-router-dom";
import { Provider } from 'react-redux';
import store from './redux/config';
const rootNode = document.getElementById('root');
const root = createRoot(rootNode)
root.render(
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>,
</Provider>,
);
// 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();