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

fix(compat): upgrade SearchBox lifecycle #2288

Merged
merged 2 commits into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Haroenv marked this conversation as resolved.
Show resolved Hide resolved
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