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

147
Vistas
React-router You cannot push the same route... force History.push / reload component

I'm trying to get my search bar working correctly.
When making a search, router sends me to /list/(whatever I searched for)

The searchbar is changing my route programmatically like so:

var pathname = '/list/';
        var query = {
            q: this.state.searchBar
        };
        hashHistory.push({pathname, query});  

/list/:q has a componentDidMount function that sends a GET request to a database, but if I make a new search while allready on '/list/:q' the url gets updated but the component is not reloaded.

My problem: How can I force my component to reload when making a new search while already on the search route /'list/:q'?

Relevant code:
Pastebin link

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

As Paul S suggested, using componentWillReceiveProps solved my problem.

over 4 years ago · Santiago Trujillo Denunciar
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