install latest versionnpm 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>; }}
install latest versionnpm install react-router-domFor v6 use belowimport 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>;}}