Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(compat): upgrade SearchBox lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Apr 23, 2019
1 parent f94b6ed commit 2b340d3
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/react-instantsearch-dom/src/components/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,13 @@ class SearchBox extends Component {
document.removeEventListener('keydown', this.onKeyDown);
}

componentWillReceiveProps(nextProps) {
// @TODO: should component maybe be controlled, otherwise Derived

// Reset query when the searchParameters query has changed.
// This is kind of an anti-pattern (props in state), but it works here
// since we know for sure that searchParameters having changed means a
// new search has been triggered.
componentDidUpdate(prevProps) {
if (
!nextProps.searchAsYouType &&
nextProps.currentRefinement !== this.props.currentRefinement
!prevProps.searchAsYouType &&
prevProps.currentRefinement !== this.props.currentRefinement
) {
this.setState({
query: nextProps.currentRefinement,
query: this.props.currentRefinement,
});
}
}
Expand Down

0 comments on commit 2b340d3

Please sign in to comment.