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

200
Views
Reaccionar enrutador e historial

Hola, soy realmente nuevo en reaccionar y estoy viendo este maravilloso tutorial de youtube ReactJs de Learncode.academy. Este tutorial es del año pasado, no sé si estos módulos ya están obsoletos. Recibí estos mensajes de error:

Ha proporcionado un objeto de historial creado con history v4.x o v2.x y anteriores. Esta versión de React Router solo es compatible con objetos de historial v3. Cambie a la historia v3.x. en invariante Aquí está mi código:

 import Layout from "./components/Layout"; import { Router, Route, IndexRoute, browserHistory } from "react-router"; const app = document.getElementById('app'); ReactDOM.render( <Router history="{browserHistory}"> <Route path="/" component="{Layout}"> </Route> </Router>, app);

Aquí está mi paquete.json

 "history": "^3.2.1", "react-router": "^3.0.2",

¡Cualquier sugerencia sería muy apreciada! ¡Gracias!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Está utilizando el historial y los componentes de forma incorrecta. No necesita comillas sobre el historial y los objetos componentes.

 import Layout from "./components/Layout"; import { Router, Route, IndexRoute, browserHistory } from "react-router"; const app = document.getElementById('app'); ReactDOM.render( <Router history={browserHistory}> <Route path="/" component={Layout}> </Route> </Router>, app);
over 4 years ago · Santiago Trujillo Report

0

De https://github.com/ReactTraining/react-router/issues/353

Para que el nombre base funcione para react-router@3.0.2:

npm install --save react-router@3.0.2

npm install --save history@^3.0.0

(verifique react-router package.json para obtener la versión de historial correcta para usar, la versión principal actual de history es 4.x y no funcionará con react-router@3.0.2)

 import React from 'react' import { render } from 'react-dom' import { Router, Route, IndexRoute, useRouterHistory } from 'react-router' import { createHistory } from 'history' const history = useRouterHistory(createHistory)({ basename: '/subdirectory-where-the-app-is-hosted-goes-here' }) render(( <Router history={history}> <Route path='/' component={Layout}> <IndexRoute component={HomeView} /> <Route path='other-views' component={OtherViews} /> </Route> </Router> ), document.getElementById('main'))
over 4 years ago · Santiago Trujillo 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!