Skip to content

Commit

Permalink
fix: remove unnecessary state in NumbersBlock Edit component
Browse files Browse the repository at this point in the history
  • Loading branch information
deodorhunter committed Nov 14, 2023
1 parent 9a14ff6 commit 0706ac3
Showing 1 changed file with 9 additions and 38 deletions.
47 changes: 9 additions & 38 deletions src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,6 @@ class Edit extends SubblocksEdit {
super(props);
this.state.selectedField = 'title';

this.state = {
...this.state,
icon1: '',
icon2: '',
icon3: '',
};
}

componentDidMount() {
this.setIconValues(this.props.data);
}

componentDidUpdate(prevProps) {
if (prevProps.data !== this.props.data) {
this.setIconValues(this.props.data);
}
}

setIconValues(data) {
this.setState({
icon1: data.icon1,
icon2: data.icon2,
icon3: data.icon3,
});
}

/**
* Render method.
* @method render
Expand Down Expand Up @@ -115,18 +89,15 @@ class Edit extends SubblocksEdit {
this.props.data.icon2 ||
this.props.data.icon3 ? (
<div className="icons">
{this.state.icon1?.length > 0 &&
this.state.icon1 === this.props.data.icon1 && (
<Icon icon={this.state.icon1} />
)}
{this.state.icon2?.length > 0 &&
this.state.icon2 === this.props.data.icon2 && (
<Icon icon={this.state.icon2} />
)}
{this.state.icon3?.length > 0 &&
this.state.icon3 === this.props.data.icon3 && (
<Icon icon={this.state.icon3} />
)}
{this.props.data.icon1?.length > 0 && (
<Icon icon={this.props.data.icon1} />
)}
{this.props.data.icon2?.length > 0 && (
<Icon icon={this.props.data.icon2} />
)}
{this.props.data.icon3?.length > 0 && (
<Icon icon={this.props.data.icon3} />
)}
</div>
) : (
<div className="icons placeholder">
Expand Down

0 comments on commit 0706ac3

Please sign in to comment.