mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 22:25:09 +00:00
Update react-router examples to use v6 version (#4199)
* Update react-router examples to use v6 version The exemple used to demonstrate Code-Splitting using react-router-dom is outdated. My suggestion is to use the new way of calling routes that was introduced in React Router v6 * remove index prop
This commit is contained in:
committed by
GitHub
parent
0b21acb5ab
commit
e0aed3fbfb
@@ -178,7 +178,7 @@ Here's an example of how to setup route-based code splitting into your app using
|
||||
|
||||
```js
|
||||
import React, { Suspense, lazy } from 'react';
|
||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
|
||||
const Home = lazy(() => import('./routes/Home'));
|
||||
const About = lazy(() => import('./routes/About'));
|
||||
@@ -186,10 +186,10 @@ const About = lazy(() => import('./routes/About'));
|
||||
const App = () => (
|
||||
<Router>
|
||||
<Suspense fallback={<div>Loading...</div>}>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Home}/>
|
||||
<Route path="/about" component={About}/>
|
||||
</Switch>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/about" element={<About />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</Router>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user