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

153
Views
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 answers
Answer question

0

As Paul S suggested, using componentWillReceiveProps solved my problem.

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!