Use React Router Dom V6

  



install latest version
npm install react-router-dom

For v6 use below

import React, { Component } from 'react';
import Navbar from './Components/Navbar';
import News from './Components/News';

import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
export default class App extends Component {

render() {
return <div>
<Router>
< Navbar />
<Routes>
<Route exact path="/" element={<News pageSize={8} category="general"/>}/>
<Route exact path="/business" element={<News pageSize={4} category="business"/>}/>
<Route exact path="/entertainment" element={<News pageSize={4} category="entertainment"/>}/>
<Route exact path="/general" element={<News pageSize={4} category="general"/>}/>
</Routes>
</Router>
</div>;
}
}







Leave a Comment

Your email address will not be published. Required fields are marked *