Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
Cannot get property 'location' of undefined. React Router

I am trying to set up React Router in an application using MERN stack and am getting the error 'Cannot get property "location" of undefined'.

Below is where I am setting the react view engine in my express app and calling the index view where my Router is being defined.

app.set('views', __dirname + '/views');
app.engine('jsx', require('express-react-views').createEngine())
app.set('view engine', 'jsx')

app.get('/', (req,res) => {
  res.render('index.jsx')
})

here is the index.jsx file:

if(typeof window !== 'undefined') {
    ReactDOM.render(<App />, document.getElementById("root"));
}

Here is the App component.

import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, IndexRoute, hashHistory } from 'react-router'
import Home from './components/home.jsx'
import App from './app.jsx'
import ContactsIndex from './components/contacts/contactsIndex.jsx'

const AppRouter = () => {
  return (
    <Router history={hashHistory}>
      <Route path='/' component={App}>

      </Route>
    </Router>
  )
}

export default AppRouter

I have seen other people with this problem who did not include a history property when defining their router. I have history included so there seems to be something else going on. Any ideas?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda