Skip to content

Commit

Permalink
moroshko#624 Refactor to move code out of deprecated componentWillRec…
Browse files Browse the repository at this point in the history
…ieveProps in Autowhatever component
  • Loading branch information
lregla committed Jan 12, 2021
1 parent a71d406 commit 5584601
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/Autowhatever.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,18 @@ export default class Autowhatever extends Component {
this.ensureHighlightedItemIsVisible();
}

// eslint-disable-next-line camelcase, react/sort-comp
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.items !== this.props.items) {
this.setSectionsItems(nextProps);
}
componentDidUpdate(prevProps) {
const itemsDidChange = prevProps.items !== this.props.items;

if (
nextProps.items !== this.props.items ||
nextProps.multiSection !== this.props.multiSection
) {
this.setSectionIterator(nextProps);
if (itemsDidChange) {
this.setSectionsItems(this.props);
}

if (nextProps.theme !== this.props.theme) {
this.setTheme(nextProps);
if (itemsDidChange || prevProps.multiSection !== this.props.multiSection) {
this.setSectionIterator(this.props);
}
if (prevProps.theme !== this.props.theme) {
this.setTheme(this.props);
}
}

componentDidUpdate() {
this.ensureHighlightedItemIsVisible();
}

Expand Down

0 comments on commit 5584601

Please sign in to comment.