Skip to content

Commit

Permalink
Remove dup code, solve whitespace issue
Browse files Browse the repository at this point in the history
  • Loading branch information
silviubogan committed Oct 12, 2020
1 parent 20603e3 commit ed5dd18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ColumnsBlock/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@
.layout-select-widget-selection-icon {
vertical-align: middle;
margin-right: 1.5rem;
}
}
15 changes: 6 additions & 9 deletions src/Widgets/LayoutSelectWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class LayoutSelectWidget extends Component {
selectedOption: null,
};

componentDidMount() {
updateSelectedOption = () => {
this.setState({
selectedOption: {
value: this.props.value,
Expand All @@ -97,18 +97,15 @@ export class LayoutSelectWidget extends Component {
)?.[1],
},
});
};

componentDidMount() {
this.updateSelectedOption();
}

componentDidUpdate(prevProps) {
if (!isEqual(prevProps.value, this.props.value)) {
this.setState({
selectedOption: {
value: this.props.value,
label: this.props.choices.find((x) =>
isEqual(x[0], this.props.value),
)?.[1],
},
});
this.updateSelectedOption();
}
}

Expand Down

0 comments on commit ed5dd18

Please sign in to comment.