Skip to content

Commit

Permalink
added exact route for home route and implemented withRouter HOC into …
Browse files Browse the repository at this point in the history
…the searchbar to navigate the user to results route
  • Loading branch information
Maxnelson997 committed Apr 27, 2018
1 parent 8aaf531 commit 22c10da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function main() {
<Provider store={createStoreWithMiddleware(reducers)}>
<BrowserRouter>
<Switch>
<Route path='/' component={Home}/>
<Route path='/' exact component={Home}/>
<Route path='/results' component={Results}/>
</Switch>
</BrowserRouter>
Expand Down
6 changes: 5 additions & 1 deletion src/components/searchBar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { Component } from 'react';
import { Field, reduxForm} from 'redux-form';

import { withRouter } from 'react-router-dom';

class SearchBar extends Component {

handleFormSubmit = function({query}) {
console.log('trying to handle submit for query', query);
//navigate to a new route.
this.props.history.push('/results');
}

renderInput(field) {
Expand All @@ -28,4 +30,6 @@ SearchBar = reduxForm({
form: 'searchBar'
})(SearchBar);

SearchBar = withRouter(SearchBar);

export default SearchBar;

0 comments on commit 22c10da

Please sign in to comment.