Skip to content

Commit 491ba33

Browse files
committed
refactor: update index.js file for react v18
1 parent ac8d5fe commit 491ba33

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import { BrowserRouter as Router, Route } from 'react-router-dom';
2+
import { createRoot } from 'react-dom/client';
3+
import { BrowserRouter, Route, Routes } from 'react-router-dom';
54
import App from './App';
5+
import './index.css';
66

7-
ReactDOM.render(
7+
const rootElement = document.getElementById('root');
8+
const root = createRoot(rootElement);
9+
root.render(
810
<React.StrictMode>
9-
<Router>
10-
<Route path='/' component={App} />
11-
</Router>
11+
<BrowserRouter>
12+
<Routes>
13+
<Route path='/*' element={<App />} />
14+
</Routes>
15+
</BrowserRouter>
1216
</React.StrictMode>,
13-
document.getElementById('root'),
1417
);

0 commit comments

Comments
 (0)