diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-06-26 22:25:55 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-06-26 22:25:55 +0200 |
commit | dedf8025a547d698d9f2e62f0897493d61ffadd5 (patch) | |
tree | bb1736fad1f20294c0ce9b53d6d33c07e7d1dcfe /src/client/react/components/container/Search.js | |
parent | 315adeb5e2012b7f7bcfcd1478f9d6dd2cc1092d (diff) |
Use mapStateToProps for router simplification
Diffstat (limited to 'src/client/react/components/container/Search.js')
-rw-r--r-- | src/client/react/components/container/Search.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/client/react/components/container/Search.js b/src/client/react/components/container/Search.js index 5f00384..65b2933 100644 --- a/src/client/react/components/container/Search.js +++ b/src/client/react/components/container/Search.js @@ -26,7 +26,7 @@ import { withRouter } from 'react-router-dom'; import SearchIcon from 'react-icons/lib/md/search'; -import { setUser, userFromMatch } from '../../lib/url'; +import { makeSetUser, userFromMatch } from '../../lib/url'; import users from '../../users'; import Menu from './Menu'; @@ -43,9 +43,7 @@ class Search extends React.Component { // react-router match: PropTypes.object.isRequired, - location: PropTypes.object.isRequired, - history: PropTypes.object.isRequired, - + setUser: PropTypes.func.isRequired, // redux dispatch: PropTypes.func.isRequired, }; @@ -99,8 +97,7 @@ class Search extends React.Component { selectedResult, results, match, - location, - history, + setUser, dispatch, } = this.props; @@ -131,7 +128,7 @@ class Search extends React.Component { // Therefor, we need to dispatch the SET_USER command manually. dispatch({ type: 'SEARCH/SET_USER', user: urlUser }); } else if (result) { - setUser(result, location, history); + setUser(result); } break; @@ -186,7 +183,8 @@ class Search extends React.Component { } } -const mapStateToProps = state => ({ +const mapStateToProps = (state, { location, history }) => ({ + setUser: makeSetUser(location, history), results: state.search.results, searchText: state.search.text, selectedResult: state.search.selected, |