6

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

Chris
  • 185
  • 1
  • 4
  • 13

1 Answers1

0

As Paul S suggested, using componentWillReceiveProps solved my problem.

Chris
  • 185
  • 1
  • 4
  • 13