The update for React (v6) and creating routes

npx create-react-app demo-projectcd demo-project
npm install react-router-dom 
import {BrowserRouter as Router, Route, Switch} from 'react-router-dom'
import React from 'react'
import Home from './Home'
class App extends React.Component {render(){
return (
<Router>
<div className="App">
<Switch>
<Route exact path='/' component={Home}/>
</Switch>
</div>
</Router>
)
}
}
export default App
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
import React from 'react'
import Home from './Home'
function App() {return (
<Router>
<Routes>
<Route index path="/" element={<Home/>}/>
</Routes>
</Router>
)
}

--

--

--

A software engineering student at Flatiron School.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why Web Developers and Web Designers Need Mentors

My Journey into Web Development Pt. 1

5 Advantages of Working with Figma

CRUD in Angular 7 Material. | Tech Influencer

Create Memes Generator with NodeJS

React Native App using Realm Database

Design Patterns in Action(7)- Proxy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jessica Sewell

Jessica Sewell

A software engineering student at Flatiron School.

More from Medium

Simple data fetching with custom React hooks and SWR

How to Build a Scalable Application with React and Redux

Some react concepts