refactor: stop using unsafe or deprecated React methods (#1542)

This commit is contained in:
Caleb
2018-07-31 14:59:22 -06:00
committed by Shawn Erquhart
parent 95c744ee3e
commit d5f59de2d2
10 changed files with 53 additions and 57 deletions

View File

@ -82,14 +82,17 @@ export default class RelationControl extends React.Component {
}
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
/**
* Load extra post data into the store after first query.
*/
if (this.didInitialSearch) return;
if (nextProps.queryHits !== this.props.queryHits && nextProps.queryHits.get && nextProps.queryHits.get(this.controlID)) {
if (this.props.queryHits !== prevProps.queryHits && this.props.queryHits.get && this.props.queryHits.get(this.controlID)) {
this.didInitialSearch = true;
const suggestion = nextProps.queryHits.get(this.controlID);
const suggestion = this.props.queryHits.get(this.controlID);
if (suggestion && suggestion.length === 1) {
const val = this.getSuggestionValue(suggestion[0]);
this.props.onChange(val, { [nextProps.field.get('collection')]: { [val]: suggestion[0].data } });
this.props.onChange(val, { [this.props.field.get('collection')]: { [val]: suggestion[0].data } });
}
}
}