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:
Jonatas de Oliveira Coêlho
2022-01-18 14:28:35 -03:00
committed by GitHub
parent 0b21acb5ab
commit e0aed3fbfb

View File

@@ -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>
);