Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
react router and routes is not working , i could not able to navigate to blogs page

react router and routes is not working , i could not able to navigate to blogs page . App.js - the following code snippet contains the App.js and the router . i could not use switch due to the latest version of react js .

import './App.css';
import React,{Component} from 'react';
import { Navbar,Nav,Container,Row,Col,Button } from 'react-bootstrap';
import {Navigation} from './navbar/navbar.js';
import Luckywheel from './luckywheel/luckywheel';
import Luckymessage from './luckywheel/luckymessage';
import {Routes , Route , BrowserRouter as Routers} from 'react-router-dom'
import Blogs from './tools/blogs';

function App() {
  return (
    <div className="App">
      <h1 className='heading'>LUCKY DRAWER</h1>
     
    <Routers> 
    <Navigation /> 
      <Luckywheel />
     <Luckymessage />
    
      <Routes>
        <Route path='blogs'  component={Blogs} />
        <Route path='/' exact component={App} />
   
      </Routes>
     
     
    
     </Routers>
     </div>
  );
}

export default App;

Navbar.js - this file contains the navigation bar code


import React ,{Component} from 'react';
import { Navbar,Nav,Container,NavDropdown, } from 'react-bootstrap';


export function Navigation () {
 return(
  
<Navbar bg="dark" variant="dark">
    <Container>
    
    <Navbar.Brand href='blogs'>Blogs</Navbar.Brand>
    <Navbar.Brand href='/'>Home</Navbar.Brand>
    
    
    </Container>
  </Navbar>    

 )
}

export default Navigation;

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In react-router-dom v6 the Route component API changed significantly. It no longer takes component or render or children function props, all replaced by a single element prop that takes a ReactElement (a.k.a. JSX).

Routes and Route

declare function Route(
  props: RouteProps
): React.ReactElement | null;

interface RouteProps {
  caseSensitive?: boolean;
  children?: React.ReactNode;
  element?: React.ReactElement | null;
  index?: boolean;
  path?: string;
}

Swap from component to element prop and pass the routed component as JSX.

<Routes>
  <Route path='blogs' element={<Blogs />} />
  <Route path='/' element={<App />} />
</Routes>
about 4 years ago · Juan Pablo Isaza Report

0

Install npm i react-router-dom@5.2.0 To work with switch

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!