Search state

This commit is contained in:
James Barnsley
2018-08-23 20:34:13 +12:00
parent 643ec313da
commit 5f81b8727c
5 changed files with 14016 additions and 10724 deletions

View File

@ -17,6 +17,15 @@ class SearchForm extends React.Component{
}
}
componentWillReceiveProps(nextProps){
// Term has been changed on us! This will be where the URL parameters have been
// digested and updated in the parent view
if (nextProps.term != '' && nextProps.term != this.state.term){
this.setState({term: nextProps.term});
}
}
handleSubmit(e){
e.preventDefault()

View File

@ -51,7 +51,7 @@ class Search extends React.Component{
componentWillReceiveProps(nextProps){
// Query changed
if (nextProps.params.query !== this.props.params.query){
if (nextProps.params.term !== this.props.params.term || nextProps.params.type !== this.props.params.type){
this.digestUri(nextProps);
}
@ -69,7 +69,6 @@ class Search extends React.Component{
// Triggered when the URL changes
digestUri(props = this.props){
if (props.params && props.params.type && props.params.term){
this.setState({
type: props.params.type,
term: props.params.term