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

147
Views
El enrutador React cambia la URL pero no vuelve a renderizar

React Router cambia la URL pero el componente no se procesa. Ya he buscado la respuesta, pero ninguno de esos ejemplos funciona. La versión actual de React Router y React Router DOM es 6. Mi componente principal:

 import React, { Component } from 'react'; import Header from './HeaderComponent'; import Footer from './FooterComponent'; import { Routes, Route, Redirect } from 'react-router-dom'; import Stafflist from './StaffComponent'; import {STAFFS} from '../shared/staffs'; import StaffDetail from './StaffDetailComponent'; class Main extends Component{ constructor(props){ super(props); this.state ={ staffs : STAFFS }; } render(){ const StaffWithId = ({match}) =>{ return( <StaffDetail staff={this.state.staffs.filter((staff) => staff.id === parseInt(match.params.staffId,10))}/> ) } return( <div> <Header/> <Routes> <Route exact path='/staff' element={<Stafflist staffs={this.state.staffs} />}/> <Route path='/staff/:staffId' element={StaffWithId}/> </Routes> <Footer/> </div> ); } } export default Main;

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

0

Su problema parece ser esta línea:
<Route path='/staff/:staffId' element={StaffWithId}/>

StaffWithId es un componente funcional y debe llamarse entre paréntesis < /> .
así: <Route path='/staff/:staffId' element={<StaffWithId/>}/>

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!