npm i react-router-dom@6
$ npm install react-router-dom@6
npm install react-router
# or
yarn add react-router
npm install react-router-dom@6
import * as React from "react";
import * as ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById("root")
);
/* ------------------------------- */
import { Routes, Route, Link } from "react-router-dom";
function App() {
return (
<div className="App">
<Routes>
<Route path="/" element={<Home />} />
<Route path="about" element={<About />} />
</Routes>
</div>
);
}
$ npm install react-router-dom
// How to work with react router dom in react-web
import {
BrowserRouter as Router,
StaticRouter, // for server rendering
Route,
Link
// etc.
} from "react-router-dom";
cd router-tutorial
npm install react-router-dom@6 history@5