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 (#2288)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Jun 27, 2019
1 parent 1d94345 commit c3ba42d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/react-instantsearch-dom/src/components/SearchBox.js
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
!this.props.searchAsYouType &&
prevProps.currentRefinement !== this.props.currentRefinement
) {
this.setState({
query: nextProps.currentRefinement,
query: this.props.currentRefinement,
});
}
}
Expand Down

0 comments on commit c3ba42d

Please sign in to comment.