Search state
This commit is contained in:
@ -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()
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user